Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / January 2008

Tip: Looking for answers? Try searching our database.

WaitForSingleObject in .net

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Smith - 31 Dec 2007 15:44 GMT
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.
Kerem Gümrükcü - 31 Dec 2007 16:20 GMT
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/library/system.threading.waithandle.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

Signature

-----------------------
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."

Nathan Smith - 31 Dec 2007 18:14 GMT
Thanks, that's exactly what I needed!

> H Nathan,
>
[quoted text clipped - 22 lines]
>
> Kerem
Kerem Gümrükcü - 01 Jan 2008 16:50 GMT
Hi Nathan,

>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

Signature

-----------------------
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."


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.