D
David
I am having a bit of a problem with catching an exception within a thread.
Here is the scenario:
I have a Windows Form.
I create a new thread.
This new thread calls a method in another DLL that catches an expected exception.
The method in the DLL throws the exception back out.
When in debug mode, the process just exits.
Here is some sample code:
public class myform : system.windows.form {
try {
ThreadClass cl = new ThreadClass();
Thread nThread = new Thread(new ThreadStart(cl.runprocess));
nThread.IsBackground = true;
nThread.Start();
}
catch(Exception ex) {
...
//Exception from thread is never caught
...
}
}
public class ThreadClass() {
public ThreadClass() {}
public void runprocess() {
try {
newDLL nDLL = new newDLL();
nDLL.DoSomething(); //<--- Exception occurrs and is rethrown in
// this method.
...
//Do more stuff //<-- never makes it to here
...
}
catch(Exception ex) {
//Do stuff here //<-- never makess it to here
}
}
}
The thread state after the exception occurrs is always ThreadState.Running.
What am I misssing?
-David
Here is the scenario:
I have a Windows Form.
I create a new thread.
This new thread calls a method in another DLL that catches an expected exception.
The method in the DLL throws the exception back out.
When in debug mode, the process just exits.
Here is some sample code:
public class myform : system.windows.form {
try {
ThreadClass cl = new ThreadClass();
Thread nThread = new Thread(new ThreadStart(cl.runprocess));
nThread.IsBackground = true;
nThread.Start();
}
catch(Exception ex) {
...
//Exception from thread is never caught
...
}
}
public class ThreadClass() {
public ThreadClass() {}
public void runprocess() {
try {
newDLL nDLL = new newDLL();
nDLL.DoSomething(); //<--- Exception occurrs and is rethrown in
// this method.
...
//Do more stuff //<-- never makes it to here
...
}
catch(Exception ex) {
//Do stuff here //<-- never makess it to here
}
}
}
The thread state after the exception occurrs is always ThreadState.Running.
What am I misssing?
-David