Exception Info

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello
How can I get Current Thread Infomation about catched exception. Related Resource will be more helpful. Thanks in advance

lzh_gladiator
 
Are you looking for something like this?

try
{
int i = 1;
int j = 0;
int k = i / j;
}
catch(Exception ex)
{

MessageBox.Show(System.Threading.Thread.CurrentThread.ThreadState.ToString()
);
}

If that's what you're looking for then you might want to check out the other
members of the Thread class.
http://msdn.microsoft.com/library/d...ml/frlrfsystemthreadingthreadmemberstopic.asp

and the CurrentThread property
http://msdn.microsoft.com/library/d...temThreadingThreadClassCurrentThreadTopic.asp


lzh_gladiator said:
Hello:
How can I get Current Thread Infomation about catched exception.
Related Resource will be more helpful. Thanks in advance!lzh_gladiator
 
Hello
thanks for your answers!But what i want know is the info of the exception occured thread.
 
You can show the error message by calling

ex.Message

Take a look at the Exception class to see what info you can get.
Note that an Exception may contain other exceptions, so if you want to see
them all in the messagebox you can use something like

string msg = ex.Message;
Exception ie = ex.InnerException;
while(ie != null)
{
msg += " : " + e.Message;
ie = ie.InnerException;
}
MessageBox.Show(msg);


Happy coding!
Morten Wennevik [C# MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top