Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6685311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:02:37+00:00 2026-05-26T05:02:37+00:00

I have to do the following: Public Sub OnMouseMove If mouseDownButNotYetMoved Then myObjectsStateArchive.SaveObjectsState(myCurrentObjectsState.Clone()) End

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:02:37+00:00Added an answer on May 26, 2026 at 5:02 am

    You can use TaskFactory.StartNew Method available in .NET 4.
    From another article:

    the new Task pattern in .NET 4 has built-in support for
    synchronization with the UI thread. This makes writing parallel
    applications that interact with the user interface easier than ever
    before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: Imports MySql.Data.MySqlClient Imports MySql.Data.Types Public Class FormMain Private Sub
Let's say I have the following class structure (simplified from my real-world problem): Public
I have the following Public Structure Foo dim i as integer End Structure Public
I have the following code: Public Class TestClass Public Sub Main() If theGlobal IsNot
At the moment, I have the following code: Public tmr() As DispatcherTimer Public Sub
I have the following Public sub: Public Sub HowToSort() Dim i As Long, j
I have a public following sub in my code as shown below: Public Sub
I have the following code: <TestMethod()> _ Public Sub GetDirectoryEntryTest() Dim path As String
I have the following code: Imports System.IO Public Class Blah Public Sub New() InitializeComponent()
I have the following code; Public Sub writetofile() ' 1: Append playername Using writer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.