Help with ThreadPool parameter?

B

Brett Romero

I'd like to use

ThreadPool.QueueUserWorkItem( new WaitCallback( flashRowColor(dgv) ) );

in a couple of places.

I have a method the callback should use:

private void flashRowColor( object pDataGridView ){...}

I've tried several combinations of using delegate keyword, parameters
for WaitCallback() but nothing seems to work for this scenario. I'm
currently using ParameterizedThreadStart(), which works fine.

But now I want to know how to get QueueUserWorkItem working. If
QueueUserWorkItem will work somehow, can I type the "object" parameter
on WaitCallback() as DataGridView to avoid casting the target?

Thanks,
Brett
 
M

Mattias Sjögren

ThreadPool.QueueUserWorkItem( new WaitCallback( flashRowColor(dgv) ) );

Try

ThreadPool.QueueUserWorkItem(new WaitCallback(flashRowColor), dgv);


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top