Re: Async thread not freeing up UI
- From: "mark" <mark@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 14 Dec 2005 16:25:27 -0800
Cor,
Do I use the sleep function in the do loop to wait for
asyncresult.IsCompleted?
What do I do with Queue?
--
mark b
"Cor Ligthert [MVP]" wrote:
> Mark,
>
> The keywords you have to look at for what you are doing are
>
> Threading.thread.sleep(milliseconds)
>
> http://msdn2.microsoft.com/en-us/library/d00bd51t.aspx
>
> Queue class.
>
> http://msdn2.microsoft.com/en-us/library/system.collections.queue.aspx
>
> And for version 2005
>
> Backgroundworker
>
> http://msdn2.microsoft.com/en-us/library/c8dcext2.aspx
>
> It will probably make your application a lot easier.
>
> I hope this helps,
>
> Cor
>
>
> "mark" <mark@xxxxxxxxxxxxxxxxxxxxxxxxx> schreef in bericht
> news:BB72C843-E0AE-4598-AB7B-C2526CF2EF45@xxxxxxxxxxxxxxxx
> > Please consider the following thread setup intended to free-up the UI
> > while a
> > huge process takes place:
> >
> > (declare delegates) (A B and C all global)
> >
> > Private Sub AB_Click(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles AB.Click
> > Dim NoArg1 As New NoArgs(AddressOf AxB)
> > NoArg1.BeginInvoke(Nothing, Nothing)
> > End Sub
> >
> > Private Sub AxB()
> > Dim mult As New TwoArgs(AddressOf solver.Matrix_Multiply)
> > Dim AsyncResult As IAsyncResult = mult.BeginInvoke(A, B, Nothing,
> > Nothing)
> > Do Until AsyncResult.IsCompleted
> > For i = 1 To 1000000 : Next : Button3.Text = Rnd().ToString
> > Loop
> > C = mult.EndInvoke(AsyncResult)
> > do other stuff with C
> > End Sub
> >
> > Matrix_Multiply is the class solver and consumes 50% of CPU resources with
> > a
> > hyperthreading P4. It is floating point arithmatic intensive. When I run
> > the
> > program the UI is unavailable until the final C result - which is
> > double(,) -
> > is obtained. Button3.text initially shows activity but then stops. The
> > threading logic works fine with a local function that simply runs a loop
> > then
> > returns a string.
> >
> > What's wrong? How fix?
> > --
> > mark b
>
>
>
.
- Follow-Ups:
- Re: Async thread not freeing up UI
- From: Cor Ligthert [MVP]
- Re: Async thread not freeing up UI
- From: Brian Gideon
- Re: Async thread not freeing up UI
- References:
- Re: Async thread not freeing up UI
- From: Cor Ligthert [MVP]
- Re: Async thread not freeing up UI
- Prev by Date: Re: Async thread not freeing up UI
- Next by Date: Re: Detecting runtime host
- Previous by thread: Re: Async thread not freeing up UI
- Next by thread: Re: Async thread not freeing up UI
- Index(es):
Loading