thread question

A

Analizer1

c#2, vs2005
hello
i have say 5 threads running
there running a instance of the same class
so there is 5 executetasks

sample example
//this is a method of 1 thread there are 5 of these running in there own
thread
public void executetask()
{
while (_ServiceRunning)
{
try
{
if (oProcess.WorkToDo())
{
oprocess.Execute() ; // goes into process does its job no
loops and returns, oProcess has its own error handler, therefor it will do
clean up and return here
}
else
{
thread.Sleep(AppConfig.SleepSeconds*1000);
}
}
catch(Exeception ex)
{
//this loop is the top most loop..so any errors at this level are
fatal errors ie sql connection...somthing else went wrong, disk io, etc
// instead of this catch block i would like to to have a predefined
event that calls a method to handle the service ...for instance
//if the error is a sql connection error
// dont stop service try to re-connect 3 times and if not stop the
service
// any examples of how to trigger a event to call a method is very
helpful
}
}
}

thanks
 
J

Jon Skeet [C# MVP]

Analizer1 said:
c#2, vs2005
hello
i have say 5 threads running
there running a instance of the same class
so there is 5 executetasks

<snip>

I don't see that this is really a threading question - it's just a
question of how to raise an event from within a method (in particular,
from within your catch block).

See http://pobox.com/~skeet/csharp/events.html for lots of details on
events.
 

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