User Control and Exceptions in Another Thread

O

Olie

I have a little scinario and I was wondering if someone could point me
in the best direction for coding it.

I have a custom user control that plays a DVD and it starts another
thread that listens for events in the DVD such as chapter change or
position change. When the event occurs it Invokes a function in the
creatting thread to raise an event. This means that the user of the
control does not need to worry about the fact that the event originated
in another thread.

As I do not want any user code to completely kill my thread listening
for events, I put all event calls in an unfiltered catch block.

My problem is what do I do with the exceptrion now, I want to notify
the user of the control that an exception occured but I do not want to
kill my event listening thread (this is what would happen if I just
left the exception).

In the program I use the control I have a global exception handling
system but this never has a chance to handle the exception.

Any advice would be apreciated.

Olie
 
C

Cowboy \(Gregory A. Beamer\)

Create an "error" delegate. The user of the control will have to code in
this "event" or "delegate" into his code (something you should inform him
of), of course. He has the option of ignoring the code also. By raising
events, he can decide what to do. That avoids the exception issue.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside the box!
*************************************************
 
O

Olie

I was wondering about this approach but it does not seem to fit in with
the philosophy of exceptions. I understood that exceptions forced a
developer to handle them rather than giving them an option. This
approach means that a developer can quite easily be oblivious to the
exception occuring in his event code.

I did think about Invoking the exception in the creatting thread but I
thought this would be a bit confusing as an exception that occured in
his event handling code would appear to happen in my control.
 

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

Top