ThreadPool help

  • Thread starter Thread starter Carmelo
  • Start date Start date
C

Carmelo

Hi there,

I'm not an experienced C# user so I would like to ask for some help
'cause I get actually lost. Here it goes. I'm trying to use the
'ThreadPool.QueueUserWorkItem()' method in order to create a new
thread and passing through some arguments on a Data Container
class(StoreArguments class). Despite that (theorically perfect) fact,
I have some problems on taking it to the practice.
I do the following:

void Main(...)
{
ThreadPool.QueueUserWorkItem( new WaitCallback(StoreProcess),
storeArgs );
}
 
Carmelo said:
I'm not an experienced C# user so I would like to ask for some help
'cause I get actually lost. Here it goes. I'm trying to use the
'ThreadPool.QueueUserWorkItem()' method in order to create a new
thread and passing through some arguments on a Data Container
class(StoreArguments class). Despite that (theorically perfect) fact,
I have some problems on taking it to the practice.
I do the following:

void Main(...)
{
ThreadPool.QueueUserWorkItem( new WaitCallback(StoreProcess),
storeArgs );
}
.
.
.
private void StoreProcess( StoreArguments storeArgs )
{...}

Then when I compile appears the next error:
Method 'StoreProcess(StoreArguments)' does not match delegate 'void
System.Threading.WaitCallback(object)'

Anyone knows why it happen or whats wrong with my code?

Exactly what the compiler says - your StoreProcess arguments don't
match those specified by WaitCallback. You need to change it to
something like:

private void StoreProcess (object state)
{
StoreArguments storeArgs = (StoreArguments)state;
}
 
Back
Top