|
Isn't it Environment.Exit()?
MSDN[^]
best regards,
David 'DNH' Nohejl
Never forget: "Stay kul and happy" (I.A.)
|
|
|
|
|
Sounds like it. I'll try that. Thanks!
|
|
|
|
|
I hope your goal is to be able to return a value (or errorlevel) from a console app, rather than to be able to exit your program from all sorts of odd places. If so the best way is to have a return value from Main(), like so:
namespace Demo
{
class ReturnErrorLevel
{
public static int Main( string [] args )
{
if( args.Length == 1 )
try
{
return int.Parse(args[0]);
}
catch( System.Exception ex )
{
System.Console.WriteLine(ex.ToString());
}
return 0;
}
}
}
Yes, I know most people are only interested in the "answer" and not any advice or opinions, but on this one I must persist. I once got a DLL from another group in the same company and after using some facilities in it, my app would seemingly crash -- just disappear. It was driving me nuts. Looking through the source code, I discovered that in many different cases, it would do whatever calculations were required, print to standard out (another silly thing for a DLL to be doing) and exit().
Exiting from all over your app is like having a large function with tons of returns, or gotos. Life is a lot simpler if the app exits from one place -- at the end of the main entrypoint.
Matt Gerrans
|
|
|
|
|
I recently received Avalon & WinFX Community Technology Preview. I tried messing around with it a bit (Visual Studio 2005 -> new C# project) and soon found those wierd "Preview" events, like PreviewMouseMove. A quick search at internet revealed this MSDN article: The "Avalon" Input System[^]
But I still don't understand what's the practical use of them. Could anyone please help me out here ?
|
|
|
|
|
How can I get the handle to a window when it's class changes? Normally I would use FindWindow and pass it the Class and the title of the window. What do I do in the variable class case? Is there a way to find it just by the title?
/\ |_ E X E GG
|
|
|
|
|
Documentation states that the FindWindow method finds any window whose title matches the lpWindowName parameter if the lpClassName parameter is NULL.
www.troschuetz.de
|
|
|
|
|
|
|
Recently, I voiced my opinion (so what is new ) about my dislike for the underscore ("_") as a member prefix for private or protected members. Thought I would see what other think on this touchy subject. I personally find them very ugly and it makes the code harder to read. It makes member variable stand out worse than if they were in bold large type fonts.
Please take a quick moment to cast your vote below.
Vote[^]
Results[^]
Rocky <><
www.HintsAndTips.com
Me Blogs: wdevs - MSN Spaces (new)
|
|
|
|
|
How can i change text color of an item or subitem ?
Thanks!
|
|
|
|
|
See ListViewItem.ForeColor .
This space for rent!
My Blog
|
|
|
|
|
Hi,
I have a windows program with a menu that opens other Forms.
I've noticed that users will min. a Form and then later run another instance of the same Form from the menu. How do I make it so that instead of another Form opening, it just restores (displays) the Form already running in taskbar?
New to programming... thanks
|
|
|
|
|
Save your Form in a Field permanently. If it already exists you can restore it by setting the WindowState to normal and activating it as well.
WinForm.WindowState = FormWindowState.Normal;
WinForm.Activate();
|
|
|
|
|
Use the Singleton pattern. Create a static member variable in your form where you keep an instance of your form.
Add a static method to your form class called "GetInstance" (or whatever you like). In that method check to see if your static variable contains an instance of the form. If it doesn't, put one in there (using new).
Then return from GetInstance the form instance kept in your member variable.
This guarantees that as long as you always call "GetInstance" to get your form object (this will require discipline on your part) only one instance of a form will ever be created:
MyCustomForm myForm = MyCustomForm.GetInstance();
MyCustomForm myForm2 = MyCustomForm.GetInstance();
myForm.WindowState = Normal;
myForm.Activate();
This space for rent!
My Blog
|
|
|
|
|
What TypeCode does an int-Array have?
|
|
|
|
|
Here's my Problem:
I have a hashtable in which i save a TypeCode as the key and the fitting regular expression as the value.
So for System.TypeCode.Int32 it would be @"\-?\d".
But I also want to parse Numbers seperated by values . Therefore I need a TypeCode for integer/double-arrays or something like that
|
|
|
|
|
The typecode of an array is System.Typecode.Object .
This space for rent!
My Blog
|
|
|
|
|
|
HI,
I have looked at the api of the WM Format and Encoder 9.0. There is a good way to capture the whole monitor screen movements in the form of an avi file. I also read the example of Idael Cardoso about how do it.
But i have one extension to it. Basically i want to transfer the frames online. But here i cannot use the encoder broadcast mechanism. I have custom api for networking.
So my question being is there any way to capture the frames and send across the network thru Windows media format api or encoder api?
thanks
eligeti
|
|
|
|
|
I already opened a thread for that but I still don't have a clue how to simply get the X-Coordinates from the first connected Joystick.
Someone recommended me the Code on http://www.error-bank.com/microsoft.public.dotnet.languages.csharp/219796_Thread.aspx
but this Code is incomplete and I was not able to complete it yet. It's just to hard to understand it in order to complete the code.
|
|
|
|
|
Any Kind of help would be great.
|
|
|
|
|
Hi
I have some xml:
<code>
<build>
<usings>
<item>System.Threading</item>
<item>System.Drawing</item>
<item>System.Windows.Forms</item>
<item>System.Diagnostics</item>
<item>System.Microsoft.DirectX</item>
<item>D3D = Microsoft.DirectX.Direct3D</item>
</usings>
<references>
<item>System.dll</item>
<item>microsoft.directx.dll</item>
<item>microsoft.directx.direct3dx.dll</item>
<item>microsoft.directx.direct3dx.dll</item>
<item>system.data.dll</item>
<item>system.drawing.dll</item>
<item>system.windows.forms.dll</item>
<item>system.xml.dll</item>
</references>
</build>
</code>
How can I read that data from each of the items in the references?
This is some code I have at the moment:
<code>
XmlTextReader reader = null;
try
{
//Load the reader with the XML file.
reader = new XmlTextReader("test.xml");
//Parse the XML and display the text content of each of the elements.
while (reader.Read())
{
if (reader.IsStartElement())
{
if (reader.IsEmptyElement)
Console.WriteLine("<{0}/>", reader.Name);
else
{
Console.Write("<{0}> ", reader.Name);
reader.Read(); //Read the start tag.
if (reader.IsStartElement()) //Handle nested elements.
Console.Write("\r\n<{0}>", reader.Name);
Console.WriteLine(reader.ReadString()); //Read the text content of the element.
}
}
}
Console.ReadLine();
reader.ReadToDescendant("usings");
reader.
Console.WriteLine(reader.Name);
Console.ReadLine();
}
finally
{
if (reader != null)
reader.Close();
}
</code>
Thanks
|
|
|
|
|
I have developed a lot of c code and use c++ as the gui. So I down loaded Visual Studio 2005 beta version to find out a bit about c#. I was surprised that there is no windows.h file. Is this beause it is a beta version or is that the way it is with .NET?
|
|
|
|
|
You seem to have a wrong view on .Net and C#. C# has nothing to do with C or C++. But you can have managed C++ in the .Net world.
|
|
|
|
|
Is there no C in C#? I was hoping to use c# at the front end and C to do all the number crunching.
What will happen to my c/c++ code when I decide to move to .NET?
|
|
|
|