Re: Newbie: How to tell where a form has been unloaded
- From: tom <tadamsmar@xxxxxxxxx>
- Date: Tue, 11 Sep 2007 11:40:01 -0700
On Sep 11, 1:48 pm, dpb <n...@xxxxxxx> wrote:
tom wrote:
On Sep 11, 1:25 pm, dpb <n...@xxxxxxx> wrote:
tom wrote:
I have to communicate with 2 forms from one thread. The one threadUse the form Unload event.
needs to manage data acquistion hw and pump data out to the 2 forms.
So I am using Main as the one central thread, creating the form
objects in main. To pump data into the forms, I am providing a public
subroutine in the forms that Main can call.
Main gets data from the hw 100 times a second and calls the public
form subroutines.
But, the user can close one or both of the forms. Main will have to
stop pumping out data when the form is unload, but how to I detect
that a form is unloaded in Main?
Reading the section in the online help on "Creating a User Interface" in
the Programmer's Guide will give an overview that is useful...
--
Well, I use the Unload event in the form. But how could I use it in
Main?
I could add code to the Unload event in the form that would
set a bit that the Main could read. Is that what you mean?
Yes. The Unload event will be raised when the form is unloaded. It
would be cleanest (imo) to contain the code for related events there,
but the code for that event _could_ consist simply of setting a global.
Of course, you then have the issue(s) of initialization and
re-initialization and all the rest that goes along w/ a global, but
that's one way.
As Ralph says, you may want to rethink your overall application
organization. Since your thread title indicates "newbie", I'm guessing
you're experience is in procedural code. Getting a grasp around the
event-driven paradigm is tough (I know, I'm old enough that even the
thought of adding a gui to "waste" all those precious cpu clocks that
could be doing "something useful" instead was anathema to me initially :) ).
Particularly if there is some variation in what is going on between
these different forms it could simplify coding significantly to make
those actions driven by events and modularized by the associated form.
I have lots of experience developing event driven software, just not
with visual basic.
I need the single thread because of the limitations of the hardware
interface. I can't just manage the hardware interface in two
different
forms, or at least it would be much harder: I would have to solve all
sorts of problems with making the two form coordinate the sequencing
of calls to the interface subroutines.
--- Hide quoted text -
- Show quoted text -
.
- Follow-Ups:
- References:
- Prev by Date: Re: issue with vb6 browser form
- Next by Date: Re: Newbie: How to tell where a form has been unloaded
- Previous by thread: Re: Newbie: How to tell where a form has been unloaded
- Next by thread: Re: Newbie: How to tell where a form has been unloaded
- Index(es):
Relevant Pages
|