Is there a way I can get both a command line AND a windows form to run in the same application? How do I handle threading for this?
7 Replies - 5221 Views - Last Post: 30 July 2011 - 08:20 PM
#1
Windows Form and Command Line in the same application
Posted 29 July 2011 - 05:38 PM
Replies To: Windows Form and Command Line in the same application
#2
Re: Windows Form and Command Line in the same application
Posted 29 July 2011 - 08:25 PM
Yes. Create a winforms application. Go to the project properties (Project menu, last line). On the Application tab you should see a dropdown list named Output Type. Change this to Console Application.
There, you have both a window and a console.
This should be put in a FAQ somewhere
There, you have both a window and a console.
This should be put in a FAQ somewhere
This post has been edited by Momerath: 29 July 2011 - 08:25 PM
#3
Re: Windows Form and Command Line in the same application
Posted 29 July 2011 - 09:28 PM
Too short for a tutorial, no code for a snippet. But I can add this thread to the C# References thread (for all the good that seems to be doing).
#4
Re: Windows Form and Command Line in the same application
Posted 30 July 2011 - 07:40 AM
Momerath, on 29 July 2011 - 09:25 PM, said:
Yes. Create a winforms application. Go to the project properties (Project menu, last line). On the Application tab you should see a dropdown list named Output Type. Change this to Console Application.
There, you have both a window and a console.
This should be put in a FAQ somewhere
There, you have both a window and a console.
This should be put in a FAQ somewhere
Really? I don't see it get asked a lot. Maybe I'm just missing it. The only time I do this is during debugging so I can watch my Console.WriteLine statements. Which of course don't execute on release versions.
#if DEBUG
Console.WriteLine("Widget method started");
// lots of method lines
Console.WriteLine("Widget method completed");
#endif
I've added it to my personal FAQ response, in case I see it asked in the future.
#5
Re: Windows Form and Command Line in the same application
Posted 30 July 2011 - 12:37 PM
tlhIn`toq, on 30 July 2011 - 07:40 AM, said:
The only time I do this is during debugging so I can watch my Console.WriteLine statements. Which of course don't execute on release versions.
#if DEBUG
Console.WriteLine("Widget method started");
// lots of method lines
Console.WriteLine("Widget method completed");
#endif
This is mainly what I was going to use it for. Debugging; being able to track what's going on, but outside of the IDE.
I was playing around with stuff, and I also found out that I can just run Application.Run(form_goes_here) on a new thread, and as long as I started that thread from the main application process, both windows close when I exit the main application.
#6
Re: Windows Form and Command Line in the same application
Posted 30 July 2011 - 02:09 PM
You can see console output in the View-> Output window as well.
#7
Re: Windows Form and Command Line in the same application
Posted 30 July 2011 - 05:43 PM
#8
Re: Windows Form and Command Line in the same application
Posted 30 July 2011 - 08:20 PM
Ah, missed that.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|