[Guide] How to Create a Graphic User Interface (GUI)

07/07/2011 12:19 Spirited#1
Luke, an administrator here, has decided that I am to be stripped of all my rights to develop here. I'm to be banned shortly simply because I own a board. I did nothing to instigate this, and I'm sorry you will be affected by this as well (if you're reading this). After years of developing here, I won't be a member of a community so willing to take everything away. This work will remain on my board (since they seem to want competition). Best regards.
07/07/2011 12:23 Froz3n:)#2
Thanks, buddy. Good job, will help a lot of ppl including me :) I'll come with my results in few days. GJ again, and thanks :)
07/07/2011 12:32 Spirited#3
Here are some more ideas from old GUIs that I've had:
07/07/2011 12:33 zTek#4
Very nice. Very into detail. Thanks for this. +thanks
07/07/2011 12:36 Korvacs#5
I really disagree with this method to add a GUI, to start with the GUI doesnt run off the main thread, it is the main thread, so any processing that is performed on the main thread that takes more than a few ms will cause the form to freeze (not that you should be processing on the main thread anyway), accessing controls across threads will cause exceptions unless you disable the illegalcrossthread check which is usually against best practice.

A by far much better method is to add a form to the application and then call it from a dedicated thread and have a method to perform updates on that thread, and if you wish hide the original console.

Pretty sure i raised these points last time, but it seems i need to do it again.
07/07/2011 12:40 Spirited#6
Quote:
Originally Posted by Korvacs View Post
I really disagree with this method to add a GUI, to start with the GUI doesnt run off the main thread, it is the main thread, so any processing that is performed on the main thread that takes more than a few ms will cause the form to freeze (not that you should be processing on the main thread anyway), accessing controls across threads will cause exceptions unless you disable the illegalcrossthread check which is usually against best practice.

A by far much better method is to add a form to the application and then call it from a dedicated thread and have a method to perform updates on that thread, and if you wish hide the original console.

Pretty sure i raised these points last time, but it seems i need to do it again.
A form that is launched in a new thread will not be processed on the main thread. If that were true, then additional threads running new forms would freeze previous forms (which isn't the case). And what exceptions? I'm writing an object to a string and having a different thread pick it up. It's not going to create any exceptions. You can't have a try and catch for everything you code.
07/07/2011 12:42 Korvacs#7
Quote:
Originally Posted by Fаng View Post
A form that is launched in a new thread will not be processed on the main thread. If that were true, then additional threads running new forms would freeze previous forms (which isn't the case).
Yes thats correct, thats what i was saying and why a GUI should be added on a seperate additional thread to the main, not converting the application to a GUI based application which changes the entire way that application handles its threading.
07/07/2011 12:44 Spirited#8
Quote:
Originally Posted by Korvacs View Post
Yes thats correct, thats what i was saying and why a GUI should be added on a seperate additional thread to the main, not converting the application to a GUI based application which changes the entire way that application handles its threading.
I've found no proof of that statement. =|
I've asked around... nobody knows what you're talking about.
The main thread keeps running until told to close- but that's the only difference I've found.

Edit: they use the same threading classes, the output control should act like a switch if I'm not mistaking. The main void creates the main thread by checking that output setting. That's what I've thought for a while now. Additional threads, whether or not the output is set to Console or Application, act the same as they've always acted in a console project.
07/07/2011 12:57 Korvacs#9
GUI's specify a specific type of COM Threading model that can drastically change the way COM objects/threads/Garbage collection are handled, consoles use a different type which is significantly more appropriate for server based applications.

Just because nobody else is aware of this doesnt mean it doesnt exist lol...
07/07/2011 13:19 Spirited#10
Quote:
Originally Posted by Korvacs View Post
GUI's specify a specific type of COM Threading model that can drastically change the way COM objects/threads/Garbage collection are handled, consoles use a different type which is significantly more appropriate for server based applications.

Just because nobody else is aware of this doesnt mean it doesnt exist lol...
I don't know where you're getting that information from. COM is only used under .NET Framework when told to (or that's what I read at least). Where is your information coming from Korvacs?

Edit: I literally cannot find any internet resource stating what you're saying.
07/07/2011 13:53 Korvacs#11
Well we resolved this, COM Thread Models are a very important issue but not in this particular case (failed to read a spoiler :(), but something everyone should read up about.
07/07/2011 20:06 S/W#12
I got problem I change all Console.WriteLine to Program.WriteLine But GUI Console box don't print any text :(
07/07/2011 21:08 BaussHacker#13
I have never seen the point of making a GUI for your server. No others than yourself is going to see it anyways. If it's to access functions etc. faster, then it's like some few seconds we talk about.
07/07/2011 23:59 Spirited#14
Quote:
Originally Posted by BaussHacker View Post
I have never seen the point of making a GUI for your server. No others than yourself is going to see it anyways. If it's to access functions etc. faster, then it's like some few seconds we talk about.
I haven't really either. I use a console. If you make a shortcut going to your console, you can change the font it uses so it looks cleaner- so I really don't care for GUIs much anymore.

Quote:
Originally Posted by S/W View Post
I got problem I change all Console.WriteLine to Program.WriteLine But GUI Console box don't print any text :(
Did you follow the guide and look at my examples? Are you starting the timer?

Quote:
Originally Posted by Korvacs View Post
Well we resolved this, COM Thread Models are a very important issue but not in this particular case (failed to read a spoiler :(), but something everyone should read up about.
We're still uncertain if it complies with STA though... I'll add that one line to it just in case. It never hurts to be safe.

Edit: Done, for all of the people that have followed the guide already, add "[MTAThread]" above your Main void.
07/08/2011 00:43 S/W#15
Quote:
Originally Posted by Fаng View Post
I haven't really either. I use a console. If you make a shortcut going to your console, you can change the font it uses so it looks cleaner- so I really don't care for GUIs much anymore.



Did you follow the guide and look at my examples? Are you starting the timer?



We're still uncertain if it complies with STA though... I'll add that one line to it just in case. It never hurts to be safe.

Edit: Done, for all of the people that have followed the guide already, add "[MTAThread]" above your Main void.
Yes