I have to do the following:
Public Sub OnMouseMove
If mouseDownButNotYetMoved Then
myObjectsStateArchive.SaveObjectsState(myCurrentObjectsState.Clone())
End If
MoveObjectsWithMouse()
End Sub
The problem is that SaveObjectsState
method is very "heavy". So, when the user moves the mouse, it expets that the object moves accordingly, but the object is "delayed", because it waits the SaveObjectsState
to be finished...
I would like to probably asynchronously do the save... I mean, all the objects are in the current thread, myObjectsStateArchive and myCurrentObjectState... just the operation of cloning and saving to be "paralelized"
What would be the best method, using ThreadPool
or something like this?
Public Sub OnMouseMove
If mouseDownButNotYetMoved Then
System.Threading.ThreadPool.QueueUserWorkItem( _
New Threading.WaitCallback( _
Sub(o)
myObjectsStateArchive.SaveObjectsState(myCurrentObjectsState.Clone())
End Sub))
End If
MoveObjectsWithMouse()
End Sub