|
I think you don't need anything going asynchronous here. Remove the OutputDataReceived event handler and the invoke to BeginOutputReadLine, so you can do it synchronously. For example:
I've not tested the code, but I guess it should work. The OutputDataReceived is only fired when a line is written on the output stream, so if there is not an end of line when it is asking for a username, you will not receive the event.
|
|
|
|
|
Why stack trace is not preserved in that code?
static void Function()
{
try
{
int[] data = new int[10];
data[100] = 1;
}
catch (Exception e)
{
throw;
}
}
static void Main(string[] args)
{
try
{
Function();
}
catch (Exception e)
{
Console.WriteLine(e.StackTrace);
}
}
The results are the same for throw or throw ex .
at ExTest.Program.Function() in ... ExTest\Program.cs:line 21
at ExTest.Program.Main(String[] args) in ... ExTest\Program.cs:line 29
Чесноков
|
|
|
|
|
You need to throw a new exception to preserve Inner Exceptions:
Try This:
try
{
Function();
}
catch(Exception ex)
{
throw new Exception("Your new error message", ex);
}
Hope this helps.
|
|
|
|
|
Documentation states that throw preserves stack trace and throw e does not.
You approach incurs handling of the inner exceptions.
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: throw e does not
incorrect.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Dear All,
I have a query in teechart.
I have created a horizontal bar chart in C# using tee chart. Now i want to change the color of the bar depending on its value(e.g. green color for positive value & red for negative).
any settings in the property?
can anyone give solution on this?
thnx
|
|
|
|
|
Hello all,
Many times during working on web projects I come across handling the customized search page for comodity. Many times it contains 10 to 20 fields which is quite a good number to pass another page and to code.
I want to know if there is any efficient way to handle such situations.
Thanks
|
|
|
|
|
Hi!!
I dint know where to post it...
But i want to know which Application of Windows responds to Win +D (used to view Desktop) and other such combinations??
Ayan
|
|
|
|
|
Windows Explorer I'd say. How is this a C# question?
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
tell me where shud i post this question...
One more thing...
Windows Explorer(explorer.exe) can read all the keystrokes??
How is this whole process is working???
Can u plz explain...
I'm just curious...
|
|
|
|
|
Windows can react to specific key combinations, known as hotkeys or hooks. Google these terms. And have a look at functions such as RegisterHotKey and http://support.microsoft.com/kb/318804[^]. Explorer must be using one of those.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks...
But i dint get anywhere...
Thanks anyway...
|
|
|
|
|
Hi!!
I wanna code a method that can restart the application without any user involvment..
I mean when an error is encountered, the method can be used to restart the application..
Plz help me out...
|
|
|
|
|
You can use following code to do so
Application.Exit();
Process.Start(Application.ExecutablePath, "/restart" + Process.GetCurrentProcess().Id);
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
How will it work can u plz explain..
i mean after this Application.Exit(); how will Process.Start(...); will be executed???
|
|
|
|
|
Ok its working....
Thanks for this...
But will it work on a Console Application too...
I cudnt find this Application...
How shud i integrate it in my code??
Its not exiting but ya its opening another instance...
How shud i get it working...
|
|
|
|
|
Try following code
Close();
System.Diagnostics.Process.Start(Application.ExecutablePath);
or you can also do following
Add using System.Windows.Forms; to the top and call
Application.Restart();
You may need to add the reference: "System.Windows.Forms.dll" to your project.
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Close() cant be used... m using Visual Studio 2010 n its not allowing... I mean its giving error...
And Application.Restart() is working fine but it aint closing the previous instance...
How shud i close the console window forcibly.. Should i use Process.Kill()??
|
|
|
|
|
Ya you can also go for kill method to kill your process...
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
To kill the application i've used
Process.GetCurrentProcess().Kill();
To restart
{
Process.Start(Application.ExecutablePath, "/restart" + Process.GetCurrentProcess().Id);
Process.GetCurrentProcess().Kill();
}
Thanks for the help...
If u can find anyother more appropriate way plz let me know...
Ayan
|
|
|
|
|
Application.Restart();
stops the current process and starts a new identical one.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
This one wont work in console application...
this will open a new instance of the application but cant close the current instance...
|
|
|
|
|
How was Luc supposed to know it was a Console application? You didn't volunteer this info up front.
|
|
|
|
|
|
Hello Everybody,
I am continue my question and it's answer with a new problem.
My New Problem is : I have two Notepad First One is in Hindi Keyboard Language and Second is Abrahic. Now I am
Trying to Hook Keycode. But I am not able to check the Active Windows Keyboard Layout.
My Previous Questions is:
http://www.codeproject.com/Messages/3753244/Keyboard-Language-and-Settings.aspx[^]
It's Answer is : Unicode Capturing
If you can think then I Can.
|
|
|
|