473,507 Members | 2,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

User Control and Exceptions in Another Thread

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

Sep 4 '06 #1
2 1836
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!
*************************************************
"Olie" <ow****@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
>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

Sep 4 '06 #2
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.

Cowboy (Gregory A. Beamer) wrote:
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!
*************************************************
"Olie" <ow****@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
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
Sep 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6752
by: Dave | last post by:
Hello all, Unfortunately, the reference I have is a bit slim on describing how to create user-defined exceptions derived from std::exception. I think what I have below will work, but is it the...
6
4190
by: Iain | last post by:
Hey folks, (I posted this in microsoft.public.dotnet.csharp.general yesterday, but it appears that this group is rather more lively) For the application I am developing, I have a data access...
3
3388
by: Robert Rotstein | last post by:
It appears that exception handling at the top-most level of a C# program, in the static void Main() method, differs depending on whether the program is run in debug mode or not. That is, code such...
8
1488
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from my user control I want to catch this in my container page. Is this possible? I don't want any event to be raised. PLEASE...
11
1882
by: BoloBaby | last post by:
OK, check this out... I have a form with a panel control and button on it (outside the panel control). I have two event handlers - one handles the click event of the button on the form. The...
5
4062
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
8
3157
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
2
2099
by: Alexander Eisenhuth | last post by:
Hallo Alltogether, I've searched in this mailing list, but it seems to me that there is no general approach to pass exceptions from one thread to another. I think most application do a unique...
1
2904
by: Efi Merdler | last post by:
Hi, I created a user control, but instead of handling exception in the user control level I prefer to handle them in the containing form. In the load event of the containing form I'm using:...
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
758
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.