Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, I have a project consist of 2 form, the main form and calculation form. the calculation form contain timer that will auto perform some calculation every 15 seconds where the calculation itself will take 5 seconds to be completed.

form calculation is call by push button from main form. the problems is that when form calculation performing its calculation, main form is stop from responding. main form will resume function once form calculation complete its activity.

now this is not related to cpu power etc, the whole program only consume 3% of my resource during operations.

What I have tried:

is there a way to make both form to run without has to wait other form complete its task.

program is written in vb.net (visual studio 2019) on windows 10.
Posted
Updated 17-Apr-20 5:06am

That's by design. Your app has one UI thread, which handles updates for all forms in the app. If any part of your code starts doing something that takes a long time, no forms will be updated until it stops doing it.

You don't need to use a second form (unless you want to), but you do need to use a second thread. I'd strongly suggest you try a BackgroundWorker[^] which is pretty easy to set up, and contains progress reporting as well (which can get cumbersome with a straight Thread). Move all your long runnign code into that, and you UI will continue to respond normally.
 
Share this answer
 
Comments
Maciej Los 17-Apr-20 11:08am    
5!
Seems you need to open second form in another task (thread). See: Using threads and threading | Microsoft Docs[^]

Here is very interesting article on CP: Multithreading with VB.NET - A beginner's choice[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900