|
-
Jul 25th, 2006, 05:05 AM
#1
Thread Starter
Member
[2.0] Form on its own Thread.
Is there a good way to put a form on its own thread so the GUI doesn't lag out on large processing?
-
Jul 25th, 2006, 01:22 PM
#2
Re: [2.0] Form on its own Thread.
I'm not sure if I understand your question very well but Forms and other controls painting is .NET built-in, so there is no way you can modify that unless you'd write them from scratch (which is near impossible)
But you can go the other way and do the large processing in a separate thread
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 25th, 2006, 04:30 PM
#3
Re: [2.0] Form on its own Thread.
One common method is to load two forms... a splash screen and the regular form. The regular form is invisible until its processing is complete, while the splash screen shows. Until processing is complete. Then switch.
-
Jul 25th, 2006, 05:03 PM
#4
Re: [2.0] Form on its own Thread.
And If you're processing happens after form_load you can use this.SuspendLayout(); and this.ResumeLayout(); to pause Form painting
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 25th, 2006, 05:56 PM
#5
Re: [2.0] Form on its own Thread.
You should supply a little more information about exactly what the issue is so people can advise what the best solution might be.
-
Jul 29th, 2006, 05:00 PM
#6
Thread Starter
Member
Re: [2.0] Form on its own Thread.
Alright, the problem is I have a server application written. During some processes, such as connecting to a database.. if that connection fails, it freezes the entire GUI until it timesout and errors. So I figured if i put the form on its own little thread, the GUI would still be fine, no matter what process would freeze up the application.
-
Jul 30th, 2006, 03:04 AM
#7
Re: [2.0] Form on its own Thread.
I suggest you put the DB layer in a separate thread, rather than the other way round.
-
Jul 30th, 2006, 06:03 AM
#8
Re: [2.0] Form on its own Thread.
The entire UI should be executed in the main thread. The idea is to perform potentially long-running operations in there own thread so, as penagate says, it should be the data access operation that gets performed in a worker thread.
-
Aug 11th, 2006, 10:05 AM
#9
Thread Starter
Member
Re: [2.0] Form on its own Thread.
Revisiting question..
It doesn't really seem feasible to have a bunch of other threads running.. this is a server application where the console gets a lot of text input to it. Adding tons of stuff to it lags the GUI.. which in turn seems to lag other things.
I need to carry on my GUI in its own thread.. I have two other threads going as well.. one for the network listener, and another for a game loop that continually runs. Ideally, those two threads will remain, with a new thread for the form, and if I understand correctly, all the other operations (usually small, short operations that are run a lot of times throughout the application) will be in the original thread.
currently the form starts at startup and everything else loads around that. If there's a way to start a separate class and then start the form in a thread, and my other stuff from the original class as well, that would be great. Is there anyway to do this?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|