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 / November 2006

Tip: Looking for answers? Try searching our database.

Button Events vs. Timer Callback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 08 Nov 2006 22:34 GMT
Greetings,

We have a circumstance where we have a series of individual buttons,
whose functionality works. This consists of sending a message to an
RS-232 port, and awaiting a reply asynchronously.

When a button is clicked, the message is sent, and we await bytes that
are received via a delegated event. This all works as expected when we
click the buttons individually.

Now we have a circumstance where we would like to organize a sequence
of these commands, timed according to a threaded timer.  During the
timer callback, we'll BeginInvoke() and subsequently call each of the
button event handlers one after the other.

The protocol has a built-in timeout feature, also a timer callback,
which effectively terminates the attempted receipt of response.

Incidentally, this may be important as well, our "protocol" of sent and
received data is such that we await the response received from one sent
message and set an AutoResetEvent when it is fully received.

As it relates to the callback, we start with the first call, we have
verified we first sent the message, and then (by what we think is how
the design ought to work) we should await an asynchronous response from
the RS-232 port.

This does not seem to be happening, so we're wondering whether there is
some sort of a timer or threading issue blocking us from actually
receiving this response. We are fairly certain that we are also
changing the timeout timer, which we are also not seeing any evidence
of.

This is very tricky because it is timers, threads, and synchronizing
this sequence of events. So we're hopeful that someone can offer some
of their insights in these areas.

Best regards,
Michael Powell
Mike - 10 Nov 2006 15:03 GMT
Stepping back for a moment... We'll have to read up on Timers and their
Callbacks, because it seems that a Timer callback is not necessarily
kosher with event handlers (i.e. as it relates to a test timer
operating in conjunction with a serial data received event handler).

I'm sure there's probably a solution in between there somewhere. In
essence, ideally we'd like for the Timer callback to work in
conjunction with the subsequent event handlers, but since that doesn't
appear to be happening, we need to find a balance somewhere in between.

There are at least a couple of options as I see it (more design related
than anything else):

1) We can separate the test timer into "steps" and execute each step
successively on each callback. This would call down to the serial port
synchronously, which is working, but which is horribly slow, especially
for large quantities of data. Which is also blocking the main
application thread while it is running (not a good thing).

**** Or ****

2) Find some alternative to the timer callback which is happy in
conjunction with serial port asynchronous data read events.

Mainly thinking out loud at this point...

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.