Connecting Tech Pros Worldwide Help | Site Map

Mouse move multithreading problem

Boni
Guest
 
Posts: n/a
#1: Nov 21 '05
Dear all,
picturebox mouse move seems to start new thread each time it is called.
At least I see in debuger many threads.
---Non user code--
Picturebox.MouseMove

This seems to spoil my algorithm.
SyncLock Me
Do()
EndSyncloc

Don't fixes the problem.
Any advice would be greatly apreciated.
Best regards,
Boni


Herfried K. Wagner [MVP]
Guest
 
Posts: n/a
#2: Nov 21 '05

re: Mouse move multithreading problem


"Boni" <oilia@nospam> schrieb:[color=blue]
> picturebox mouse move seems to start new thread each time it is called.
> At least I see in debuger many threads.[/color]

I am not able to reproduce this behavior with .NET 1.1. Are you talking
about the control's 'MouseMove' event? Please post the relevant parts of
your source code.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Boni
Guest
 
Posts: n/a
#3: Nov 21 '05

re: Mouse move multithreading problem


Dear Herfried,
I use NET 1.1.

Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove

DoMove()

PictureBox1.Invalidate()

End Sub

Sub DoMove()

SyncLock m_Graph

Recalculate()

End SyncLock

End Sub



If some of internal assertions in Recalculate fails, I see in a debugger not
only one stack, but many of them.





"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb im Newsbeitrag
news:OC6ZaJZzFHA.1032@TK2MSFTNGP12.phx.gbl...[color=blue]
> "Boni" <oilia@nospam> schrieb:[color=green]
>> picturebox mouse move seems to start new thread each time it is called.
>> At least I see in debuger many threads.[/color]
>
> I am not able to reproduce this behavior with .NET 1.1. Are you talking
> about the control's 'MouseMove' event? Please post the relevant parts of
> your source code.
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>[/color]


Boni
Guest
 
Posts: n/a
#4: Nov 21 '05

re: Mouse move multithreading problem


I added to DoMove a flag to see, if I am right about the multithreading, and
assertion often fails.

Dim a As Boolean = False

Sub DoMove()

SyncLock m_Graph

If (a) Then

Debug.assert(false, "Multithreading!!!!")

End If





a = True

....



Recalculate()
a=false

End SyncLock
....

"Boni" <oilia@nospam> schrieb im Newsbeitrag
news:eljQBIbzFHA.2076@TK2MSFTNGP14.phx.gbl...[color=blue]
> Dear Herfried,
> I use NET 1.1.
>
> Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
>
> DoMove()
>
> PictureBox1.Invalidate()
>
> End Sub
>
> Sub DoMove()
>
> SyncLock m_Graph
>
> Recalculate()
>
> End SyncLock
>
> End Sub
>
>
>
> If some of internal assertions in Recalculate fails, I see in a debugger
> not only one stack, but many of them.
>
>
>
>
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb im
> Newsbeitrag news:OC6ZaJZzFHA.1032@TK2MSFTNGP12.phx.gbl...[color=green]
>> "Boni" <oilia@nospam> schrieb:[color=darkred]
>>> picturebox mouse move seems to start new thread each time it is called.
>>> At least I see in debuger many threads.[/color]
>>
>> I am not able to reproduce this behavior with .NET 1.1. Are you talking
>> about the control's 'MouseMove' event? Please post the relevant parts of
>> your source code.
>>
>> --
>> M S Herfried K. Wagner
>> M V P <URL:http://dotnet.mvps.org/>
>> V B <URL:http://classicvb.org/petition/>[/color]
>
>[/color]


TrtnJohn
Guest
 
Posts: n/a
#5: Nov 21 '05

re: Mouse move multithreading problem


Each event returned by your control is NOT on a different thread. Each
windows application has a single UI thread which is processing events. Your
event handler routines are called from this single UI thread whenever an
event is received by the window. In the background Windows messages are
being processed and routed to each window handle. Your MouseMove event
handler will receive each event synchronously so there is no need for
SyncLock.

"Boni" wrote:
[color=blue]
> I added to DoMove a flag to see, if I am right about the multithreading, and
> assertion often fails.
>
> Dim a As Boolean = False
>
> Sub DoMove()
>
> SyncLock m_Graph
>
> If (a) Then
>
> Debug.assert(false, "Multithreading!!!!")
>
> End If
>
>
>
>
>
> a = True
>
> ....
>
>
>
> Recalculate()
> a=false
>
> End SyncLock
> ....
>
> "Boni" <oilia@nospam> schrieb im Newsbeitrag
> news:eljQBIbzFHA.2076@TK2MSFTNGP14.phx.gbl...[color=green]
> > Dear Herfried,
> > I use NET 1.1.
> >
> > Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
> > System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
> >
> > DoMove()
> >
> > PictureBox1.Invalidate()
> >
> > End Sub
> >
> > Sub DoMove()
> >
> > SyncLock m_Graph
> >
> > Recalculate()
> >
> > End SyncLock
> >
> > End Sub
> >
> >
> >
> > If some of internal assertions in Recalculate fails, I see in a debugger
> > not only one stack, but many of them.
> >
> >
> >
> >
> >
> > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb im
> > Newsbeitrag news:OC6ZaJZzFHA.1032@TK2MSFTNGP12.phx.gbl...[color=darkred]
> >> "Boni" <oilia@nospam> schrieb:
> >>> picturebox mouse move seems to start new thread each time it is called.
> >>> At least I see in debuger many threads.
> >>
> >> I am not able to reproduce this behavior with .NET 1.1. Are you talking
> >> about the control's 'MouseMove' event? Please post the relevant parts of
> >> your source code.
> >>
> >> --
> >> M S Herfried K. Wagner
> >> M V P <URL:http://dotnet.mvps.org/>
> >> V B <URL:http://classicvb.org/petition/>[/color]
> >
> >[/color]
>
>
>[/color]
Boni
Guest
 
Posts: n/a
#6: Nov 21 '05

re: Mouse move multithreading problem


Dear Sirs,
I do not understand,
If MouseMove started and is still running, but other MouseMove event happens
will it wait until first one is finished? How can I force this behavoir?
Thank you very much,
Boni

"TrtnJohn" <TrtnJohn@discussions.microsoft.com> schrieb im Newsbeitrag
news:81314A38-C5A7-4A87-8A26-39EAEA88C6C1@microsoft.com...[color=blue]
> Each event returned by your control is NOT on a different thread. Each
> windows application has a single UI thread which is processing events.
> Your
> event handler routines are called from this single UI thread whenever an
> event is received by the window. In the background Windows messages are
> being processed and routed to each window handle. Your MouseMove event
> handler will receive each event synchronously so there is no need for
> SyncLock.
>
> "Boni" wrote:
>[color=green]
>> I added to DoMove a flag to see, if I am right about the multithreading,
>> and
>> assertion often fails.
>>
>> Dim a As Boolean = False
>>
>> Sub DoMove()
>>
>> SyncLock m_Graph
>>
>> If (a) Then
>>
>> Debug.assert(false, "Multithreading!!!!")
>>
>> End If
>>
>>
>>
>>
>>
>> a = True
>>
>> ....
>>
>>
>>
>> Recalculate()
>> a=false
>>
>> End SyncLock
>> ....
>>
>> "Boni" <oilia@nospam> schrieb im Newsbeitrag
>> news:eljQBIbzFHA.2076@TK2MSFTNGP14.phx.gbl...[color=darkred]
>> > Dear Herfried,
>> > I use NET 1.1.
>> >
>> > Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As
>> > System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
>> >
>> > DoMove()
>> >
>> > PictureBox1.Invalidate()
>> >
>> > End Sub
>> >
>> > Sub DoMove()
>> >
>> > SyncLock m_Graph
>> >
>> > Recalculate()
>> >
>> > End SyncLock
>> >
>> > End Sub
>> >
>> >
>> >
>> > If some of internal assertions in Recalculate fails, I see in a
>> > debugger
>> > not only one stack, but many of them.
>> >
>> >
>> >
>> >
>> >
>> > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schrieb im
>> > Newsbeitrag news:OC6ZaJZzFHA.1032@TK2MSFTNGP12.phx.gbl...
>> >> "Boni" <oilia@nospam> schrieb:
>> >>> picturebox mouse move seems to start new thread each time it is
>> >>> called.
>> >>> At least I see in debuger many threads.
>> >>
>> >> I am not able to reproduce this behavior with .NET 1.1. Are you
>> >> talking
>> >> about the control's 'MouseMove' event? Please post the relevant parts
>> >> of
>> >> your source code.
>> >>
>> >> --
>> >> M S Herfried K. Wagner
>> >> M V P <URL:http://dotnet.mvps.org/>
>> >> V B <URL:http://classicvb.org/petition/>
>> >
>> >[/color]
>>
>>
>>[/color][/color]


Closed Thread


Similar Visual Basic .NET bytes