HighTechTalks DotNet Forums  

WaitForSingleObject in .net

Dotnet Framework microsoft.public.dotnet.framework


Discuss WaitForSingleObject in .net in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Nathan Smith
 
Posts: n/a

Default WaitForSingleObject in .net - 12-31-2007 , 09:44 AM






Hi,
I'm a Win32 programmer trying to develop a vb.net app, and I'm trying to
find out what the vb.net equivalent method is for WaitForSingleObject. I
need a way to wait for an object for a specified timeout. Since I'm used to
Win32, naturally I would use WaitForSingleObject, but this is not available
in .net.

Any help would be appreciated,

Thanks.

Reply With Quote
  #2  
Old   
Kerem Gümrükcü
 
Posts: n/a

Default Re: WaitForSingleObject in .net - 12-31-2007 , 10:20 AM






H Nathan,

the WFSO Function is available in .net, since you can invoke it
with PInvoke. Its Signature is like this:

[DllImport("kernel32", SetLastError=true, ExactSpelling=true)]
internal static extern Int32 WaitForSingleObject(IntPtr handle, Int32
milliseconds);

public static uint INFINITE = 0xFFFFFFFF;

But you should not use it for some .net internal related reasons.
there is a safe "managed" class that will give you the same functionallity
but in a "safe" and .net "managed" way. The Class is called

[WaitHandle Class (System.Threading)]
http://msdn2.microsoft.com/en-us/lib...aithandle.aspx

Before i used the WaitHandle was used to call the Windows API functions
avec PInvoke but this has several drawbacks like GC issues and Handle
stuff. So use whenever you can use a managed eqivalent in your software
from the .net FW,...use it!

Regards

Kerem


--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."



Reply With Quote
  #3  
Old   
Nathan Smith
 
Posts: n/a

Default Re: WaitForSingleObject in .net - 12-31-2007 , 12:14 PM



Thanks, that's exactly what I needed!

"Kerem Gümrükcü" wrote:

Quote:
H Nathan,

the WFSO Function is available in .net, since you can invoke it
with PInvoke. Its Signature is like this:

[DllImport("kernel32", SetLastError=true, ExactSpelling=true)]
internal static extern Int32 WaitForSingleObject(IntPtr handle, Int32
milliseconds);

public static uint INFINITE = 0xFFFFFFFF;

But you should not use it for some .net internal related reasons.
there is a safe "managed" class that will give you the same functionallity
but in a "safe" and .net "managed" way. The Class is called

[WaitHandle Class (System.Threading)]
http://msdn2.microsoft.com/en-us/lib...aithandle.aspx

Before i used the WaitHandle was used to call the Windows API functions
avec PInvoke but this has several drawbacks like GC issues and Handle
stuff. So use whenever you can use a managed eqivalent in your software
from the .net FW,...use it!

Regards

Kerem


--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."




Reply With Quote
  #4  
Old   
Kerem Gümrükcü
 
Posts: n/a

Default Re: WaitForSingleObject in .net - 01-01-2008 , 10:50 AM



Hi Nathan,

Quote:
Thanks, that's exactly what I needed!
you're welcome!

See the System.Threading Namspace for more
Synchronization classes. The majority of the
Namespace is, as its name implies, for threading
and data/process synchronization. So if you have
questions about sync issues, have a look at this
namespace,...

Happy New Year,...

Regards

Kerem



--
-----------------------
Beste Grüsse / Best regards / Votre bien devoue
Kerem Gümrükcü
Microsoft Live Space: http://kerem-g.spaces.live.com/
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------
"This reply is provided as is, without warranty express or implied."




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.