Re: Major image list problem!

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Nak (a_at_a.com)
Date: 10/08/04


Date: Fri, 8 Oct 2004 12:29:05 +0100

Hi again,

    While attempting to implementing this invoking thing, I found my
problem! The listview *was* being altered on another thread but nowhere
near where I was looking, sorry for all this! That's what working too late
does to your head!

Nick.

"Nak" <a@a.com> wrote in message
news:%2300lUXSrEHA.592@TK2MSFTNGP11.phx.gbl...
> Cheers Peter,
>
> I shall start modifying it now and see how it reacts.
>
> Nick.
>
> ""Peter Huang"" <v-phuang@online.microsoft.com> wrote in message
> news:wAjjzcOrEHA.3468@cpmsftngxa06.phx.gbl...
>> Hi Nick,
>>
>> Is the updateImageThumbnail called on the backgroud working thread?
>> If so, I think we would better masharl the call on the main UI thread, it
>> is not recommend to modity UI control's property in the thread other than
>> main UI thread.
>> You may try to use the control.BeginInvoke or control.Invoke method to
>> marshal the call back to the UI control's thread(main UI thread).
>>
>> Control.Invoke Method
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
>> frlrfsystemwindowsformscontrolclassinvoketopic.asp
>>
>> Control.BeginInvoke Method
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
>> frlrfSystemWindowsFormsControlClassBeginInvokeTopic.asp
>>
>> Private Sub ChangeText()
>> Dim rd As New Random
>> Me.Button1.Text = rd.Next().ToString() 'These code will run on
>> button1's thread, Main UI thread.
>> End Sub
>> Private Sub ThreadProc()
>> For i As Integer = 0 To 10
>> Me.Button1.Invoke(New MethodInvoker(AddressOf ChangeText))
>> Thread.Sleep(1000)
>> Next
>> End Sub
>> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
>> System.EventArgs) Handles Button1.Click
>> Dim th As New Thread(AddressOf ThreadProc)
>> th.Start()
>> End Sub
>>
>> Best regards,
>>
>> Peter Huang
>> Microsoft Online Partner Support
>>
>> Get Secure! - www.microsoft.com/security
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>
>


Quantcast