Welcome Guest Login or Signup
LIVE CHAT | INSTANT MESSENGER | BOOKMARK
| LANGUAGE:
 

BLOGS   WRITE NEW BLOG   EDIT BLOGS  
 
RSS
Finally
Posted On 07/22/2010 20:53:48 by hermine

Finally,I have a confession to make. Spider plant As part of this project, I wrote and tested a complete wrapper for the Win32 Waitable Events API before stumbling on the ManualResetEvent and AutoResetEvent framework classes that already encapsulated all the functionality I needed. Remember:you just might be spending all your free time writing brand new classes from scratch when just what ugg boots for cheap you needed already existed.Check your local hardware store before reinventing the wheel.On this principle,i hope that the base classes developed here will help other LineTerm uses CommLine as its base class and illustrates how to use the library in source code.You will need to run it from the Visual Studio?IDE because there is no user interface for settings.In Visual Studio .NET,create a new Visual Basic console application.Remove the supplied default module from the project.Copy LineTerm.vb,CommBase.dll,and CommBase.Xml into the project directory (the XML file provides IntelliSense? information for the library).Use Add Existing Item in the project explorer to import LineTerm. ugg boots online vb and Add Reference to set a reference to CommBase.dll.You should now be able to build and run the project.
 Here,wo is a local variable of type Win32Com.OVERLAPPED,and ptrUWO is a private class variable of type IntPtr.Marshal is a static object in System.Runtime.InteropServices that provides access to the interop marshaler.In this code,i am doing manually what the marshaler normally does automatically when an external function is called.The first step is to allocate an appropriately sized block of unmanaged memory, christian louboutin sale then copy the contents of the managed structure into it,remapping the memory layout as required.After the function call,the marshaler would normally use Marshal.PtrToStructure to perform the reverse copy,then Marshal.FreeHGlobal to release the memory.I perform this operation manually because of the special way the API uses the OVERLAPPED structure.I will specify it in a WriteFile call,but then the operating system will continue to use it after the call returns.Programmers bring RS232 device communications into the. christian louboutin booties Once the port is opened and configured.Open invokes a virtual method AfterOpen,which may be overridden to check the status of the connection to the remote device and possibly also to configure it.If this returns false,the port will be closed again and Open itself will return false.There is also a BeforeClose method for shutting down the remote devi Before sending new data,the result of any pvious Send should be checked, enabling the detection of error conditions or timeouts.Strangely,the API treats a pending operation as an error, christian louboutin boots sale but a timeout as perfectly normal—the only way of detecting it is that fewer bytes are sent than were queued.Ironing out this kind of anomaly is one of the hidden pleasures of writing a wrapper library!Although I could allow multiple pending sends,each with its own OVERLAPPED structure,it would add a lot of complexity.Instead,I have blocked a subsequent Send until the pvious one completes.If this blocking is a problem,it can be disabled by setting the checkAllSends member to false,in which case the OVERLAPPED structure is reused and there is no guarantee that errors or timeouts will be caught.Figure 6 shows a simplified version of ReceiveThread.SetCommMask indicates that I want to be notified when a new byte arrives. christian louboutin on sale WaitCommEvent may return true,in which case there is already one or more bytes waiting.If it returns false with error code ERROR_IO_PENDING, I can suspend the thread until a byte arrives.The OVERLAPPED structure that was passed to WaitCommEvent includes the handle to an AutoResetEvent,which will be signaled when the byte arrives.When I execute the AutoResetEvent's WaitOne method,execution is suspended until the event is signaled.

Error handling and exceptions need to be carefully considered when using worker threads.Any unhandled exceptions that occur in ReceiveThread,any of the virtual methods called from it,and any methods or events called or fired from any of these will propagate up and be handled by the catch clause.If the exception is not ThreadAbortException.ykl



Bookmark:



Viewing 1 - 1 out of 1 Comments

From: ivy00135
12/15/2011 19:11:48




*** CLUBPARADA Homepages ***
Powered by phpFoX Version 1.6.20