Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 19th, 2005, 10:17 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Asynchronous Functions in C#

I have written a class in c# that uses the MSComm lib for serial communications to make calls to a remote device and retrieve data. The class has a method that when called, is writing the dial string to the port causing the modem to dial out and is then using the OnComm event to detect when the required data has come in and in case the data is correct it raises an event that also passes the data to the calling class which in turn calls another method of the comm class to terminate the call.

I would like to implement a calling class that loops through a number of such remote devices and for each one it performs the function described above. How can I implement this? It appears to me that in every iteration the loop has to wait for the event to be fired and if the data passed is correct it must terminate the call and move to the next iteration. How can I best implement such an operation?


Truly grateful for any help.


Regards

Chris

Reply With Quote
  #2 (permalink)  
Old July 23rd, 2005, 07:53 PM
Authorized User
 
Join Date: May 2004
Location: Karachi, Sindh, Pakistan.
Posts: 83
Thanks: 0
Thanked 1 Time in 1 Post
Default

Besides how the specified functionality should be implemented, consider using asynchronous method calls if you want to be able to call a method and continue execution without waiting for it to return and be automatically notified when it does.

You can call every .NET method asynchronously by simply defining a delegate of the same signature as the method that is to be called asynchronously. After instantiating the delegate, you'll notice that for each method of your class, there's a pair of methods BeginXXX and EndXXX, where XXX is the name of the methods. These methods are used to asynchronously invoke and end the XXX method. When an asynchronous method call returns, you will be notified by means of a specified callback method.

Of course this is rather superficial discussion. I just wanted to point you to the right direction. Plz see the .NET documentation to learn how to implement this functionality.

Regards,

ejan
Reply With Quote
  #3 (permalink)  
Old July 25th, 2005, 12:31 AM
Registered User
 
Join Date: Jul 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks

I will try this and let you know,

Chris

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Asynchronous Transactions jroxit Other Programming Languages 0 July 29th, 2008 11:12 AM
Asynchronous call tapan General .NET 1 April 27th, 2007 08:12 AM
synchronous and asynchronous methods mike_remember ASP.NET 1.0 and 1.1 Professional 1 December 28th, 2006 10:52 AM
XSLProcessor asynchronous transformations Vx BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 September 5th, 2006 12:41 PM
2 questions about asynchronous callbacks pooh2006 ASP.NET 2.0 Professional 0 March 24th, 2006 11:20 AM



All times are GMT -4. The time now is 11:01 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.