Re: Threads in Visual Basic?
- From: "Tony Proctor" <tony_proctor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 25 Apr 2007 17:06:05 +0100
Yup! :-)
The important thing about that example Dag is that the ActiveX EXE thread
executes asynchronously with respect to the caller (achieved by scheduling a
single-shot timer for a very short time after the call). Normally, a COM
call to the ActiveX EXE will block until that call returns. This little
trick allows it to operate asynchronously until it delivers an Event back to
the caller, as you suggested.
Tony Proctor
"Dag Sunde" <me@xxxxxxxxxxxx> wrote in message
news:462f758a$0$31540$8404b019@xxxxxxxxxxxxxxxxxx
Ray wrote:loading
Tony Proctor wrote:
That's possible Ray. The not-so-obvious bit is how to share the
loaded data later. As I said, the threads are independent in almost
every way, and share no data by default. If you were to pass the
resulting Recordset via a COM call between threads (or processes)
then it could also take a long time. Do you know why the database
is so slow? How much data are
you talking about?
Tony Proctor
It's not that much data, it's just coming over a slow WAN link, which
I'm just looking for an example or two of how to do a "background"
process in VB so the user could start to log in to the app while the
data continues to load.
Instead of making them start at a splash screen or hourglass for a
minute, I'd like the data to load in the background while they log in.
This is quite possible with an activeX exe (out-of-process) server that
loads the data, and raises an event when done.
Instance it "withevents", and your app will be notified when data is
available.
(If I remember correctly, the "CoffeeTimer" example in the VB manual
show an example of this).
If you can't grok it, post a note here, and I'll whip something together
for you... (but give it a try first... (deadlines haunt me these days)).
The best I could think of would be to use a timer and a status flag to
make sure the data load only runs once, but then I still have a timer
running every x seconds doing nothing other than going "yup, already
ran..."
That is easily fixed by setting Timer1.Enabled = False once you're done.
--
Dag.
.
- References:
- Threads in Visual Basic?
- From: SpreadTooThin
- Re: Threads in Visual Basic?
- From: Tony Proctor
- Re: Threads in Visual Basic?
- From: Ray
- Re: Threads in Visual Basic?
- From: Tony Proctor
- Re: Threads in Visual Basic?
- From: Ray
- Re: Threads in Visual Basic?
- From: Dag Sunde
- Threads in Visual Basic?
- Prev by Date: Re: Percentage Sign
- Next by Date: Re: Final Word (?) on Timers
- Previous by thread: Re: Threads in Visual Basic?
- Next by thread: Re: Threads in Visual Basic?
- Index(es):
Relevant Pages
|