PC Review


Reply
Thread Tools Rate Thread

Continously Running Thread

 
 
=?Utf-8?B?UmFlZCBTYXdhbGhh?=
Guest
Posts: n/a
 
      3rd Jan 2005
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#
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      3rd Jan 2005
Raed Sawalha <(E-Mail Removed)> 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 - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running progress indicator in different thread to UI thread Steve Microsoft VB .NET 2 10th Jul 2009 01:52 AM
Start-up running continously KarenK Windows XP Help 3 9th Feb 2008 04:39 PM
Windows Installer is continously running! =?Utf-8?B?QXdhbFNL?= Windows XP General 1 9th Apr 2006 05:37 AM
How to know if thread is still running DaWoE Microsoft ASP .NET 5 26th Nov 2004 04:30 PM
Changing thread priority when thread is running =?Utf-8?B?VFQgKFRvbSBUZW1wZWxhZXJlKQ==?= Microsoft C# .NET 3 23rd Mar 2004 02:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:32 PM.