Continously Running Thread  
Author Message
bullbreaker





PostPosted: Mon Jan 03 09:49:25 CST 2005 Top

Visual C#.Net >> Continously Running Thread Dear:

I used to code a continously running thread in C++ like following:
Handle hStopEvent = CreateEvent(NULL,true,false,NULL);
UINT uOptional = 0;
_beginthreadex(NULL,0,wtInvestigate,(LPVOID)NULL,0,&uOptional);

unsigned _stdcall
wtInvestigate(LPVOID lpParams)
{
while(true)
{
DWORD dwThreadStatus = WaitForSingleObject(hStopEvent
,DELAY_TIME);
switch(dwThreadStatus)
{
case WAIT_OBJECT_0:
//TODO
break;
case WAIT_TIMEOUT:
//TODO
break

}
}
}

How can I achieve the same procedure in C#

DotNet368  
 
 
Jon





PostPosted: Mon Jan 03 09:49:25 CST 2005 Top

Visual C#.Net >> Continously Running Thread Raed Sawalha <EMail@HideDomain.com> wrote:
> I used to code a continously running thread in C++ like following:

<snip>

> How can I achieve the same procedure in C#

Just write a never-ending method, and create a thread to run that
method in the normal way. I very rarely write methods like that though
- the thread should usually watch for a certain condition at which
point it will shut down gracefully.

See http://www.pobox.com/~skeet/csharp/threads/ for more threading
information.

--
Jon Skeet - <EMail@HideDomain.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too