Re: Newbie: How to tell where a form has been unloaded
- From: dpb <none@xxxxxxx>
- Date: Tue, 11 Sep 2007 14:00:41 -0500
tom wrote:
On Sep 11, 2:40 pm, tom <tadams...@xxxxxxxxx> wrote:On Sep 11, 1:48 pm, dpb <n...@xxxxxxx> wrote:
tom wrote:I have lots of experience developing event driven software, just notOn Sep 11, 1:25 pm, dpb <n...@xxxxxxx> wrote:Yes. The Unload event will be raised when the form is unloaded. Ittom wrote:Well, I use the Unload event in the form. But how could I use it inI 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...
--
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?
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.
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.
I am not trying to avoid implementing this completely with events in
the two different forms for no reason. l would need to:
1. Initialize the HW interface only once and wait till the
initialization is complete. Can't just initialize it in both forms.
2. Prompt for data from the HW interface. I can either get two
readings from the interface at once, one for each form, or I can get
one reading at a time, with alternating readings for each form.
Suppose I try to do this all with events in each form object. How do
you suggest that I make the forms coordinate and/or communicate? It
is probably possible but I am not sure it is any better than using
Main to kick off both forms and then managing the data acquisition in
Main.
We're posting when each other is reading the previous response, Tom! :)
Read my other two and see if that helps--if not, post in response to one (pick one) and we'll go from there. I'll then post back only on one subthread...
--
.
- References:
- Newbie: How to tell where a form has been unloaded
- From: tom
- Re: Newbie: How to tell where a form has been unloaded
- From: dpb
- Re: Newbie: How to tell where a form has been unloaded
- From: tom
- Re: Newbie: How to tell where a form has been unloaded
- From: dpb
- Re: Newbie: How to tell where a form has been unloaded
- From: tom
- Re: Newbie: How to tell where a form has been unloaded
- From: tom
- Newbie: How to tell where a form has been unloaded
- Prev by Date: Re: Newbie: How to tell where a form has been unloaded
- 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
|