473,323 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Using threading causes untrappable exception

We have developed an application which performs a series of long tasks, so
in order to keep the GUI responsive we do these tasks in a separate thread.
When run from the development environment, or run as a standalone
application on any machine with VS 2003 installed, it is fine. On any other
machine, a exception is generated at a seemingly random time during
execution. The message box simply says "Application has generated an
exception which cannot be handled."

If we do not launch these processes in a separate thread (i.e call the
method directly), the problem disappears. The very simply code we use the
create the thread is as follows:

ThreadStart activeThreadStart = new ThreadStart(dataConversion);
activeThread = new Thread(activeThreadStart);
activeThread.Start();

We have attempted to trap this error to no avail, even going so far as to
use the following:

CustomExceptionHandler eh = new CustomExceptionHandler();
Application.ThreadException += new
ThreadExceptionEventHandler(eh.OnThreadException);
Application.Run(new SummaryForm());

All target machines have framework 1.1 and MDAC 2.8. If anyone has seen this
problem, or can suggest a cause or cure, that would be great.

Michael

Nov 16 '05 #1
5 1925
Hi Michael,

You are not accessing GUI controls from worker thread, do you?
What are you doing in worker thread?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Michael Lane" <ar***@mailblocks.ca> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
We have developed an application which performs a series of long tasks, so
in order to keep the GUI responsive we do these tasks in a separate
thread. When run from the development environment, or run as a standalone
application on any machine with VS 2003 installed, it is fine. On any
other machine, a exception is generated at a seemingly random time during
execution. The message box simply says "Application has generated an
exception which cannot be handled."

If we do not launch these processes in a separate thread (i.e call the
method directly), the problem disappears. The very simply code we use the
create the thread is as follows:

ThreadStart activeThreadStart = new ThreadStart(dataConversion);
activeThread = new Thread(activeThreadStart);
activeThread.Start();

We have attempted to trap this error to no avail, even going so far as to
use the following:

CustomExceptionHandler eh = new CustomExceptionHandler();
Application.ThreadException += new
ThreadExceptionEventHandler(eh.OnThreadException);
Application.Run(new SummaryForm());

All target machines have framework 1.1 and MDAC 2.8. If anyone has seen
this problem, or can suggest a cause or cure, that would be great.

Michael

Nov 16 '05 #2
Michael Lane <ar***@mailblocks.ca> wrote:
We have developed an application which performs a series of long tasks, so
in order to keep the GUI responsive we do these tasks in a separate thread.
When run from the development environment, or run as a standalone
application on any machine with VS 2003 installed, it is fine. On any other
machine, a exception is generated at a seemingly random time during
execution. The message box simply says "Application has generated an
exception which cannot be handled."

If we do not launch these processes in a separate thread (i.e call the
method directly), the problem disappears. The very simply code we use the
create the thread is as follows:

ThreadStart activeThreadStart = new ThreadStart(dataConversion);
activeThread = new Thread(activeThreadStart);
activeThread.Start();

We have attempted to trap this error to no avail, even going so far as to
use the following:

CustomExceptionHandler eh = new CustomExceptionHandler();
Application.ThreadException += new
ThreadExceptionEventHandler(eh.OnThreadException);
Application.Run(new SummaryForm());

All target machines have framework 1.1 and MDAC 2.8. If anyone has seen this
problem, or can suggest a cause or cure, that would be great.


Are you updating the UI from the other thread, by any chance? If so,
that's probably the problem.
See http://www.pobox.com/~skeet/csharp/t...winforms.shtml

Otherwise, could you post a short but complete program which
demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Thanks very much for taking the time to reply to my post.

The thread is doing data conversion tasks which basically consist of data
copying, shuffling and manipulating for the most part. Yes, I am updating
the GUI from within the worker thread - I update a label and a progress bar.
Is this a potential source of problems? Is there a workaround?

Michael

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:ea**************@TK2MSFTNGP10.phx.gbl...
Hi Michael,

You are not accessing GUI controls from worker thread, do you?
What are you doing in worker thread?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Michael Lane" <ar***@mailblocks.ca> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
We have developed an application which performs a series of long tasks,
so in order to keep the GUI responsive we do these tasks in a separate
thread. When run from the development environment, or run as a standalone
application on any machine with VS 2003 installed, it is fine. On any
other machine, a exception is generated at a seemingly random time during
execution. The message box simply says "Application has generated an
exception which cannot be handled."

If we do not launch these processes in a separate thread (i.e call the
method directly), the problem disappears. The very simply code we use the
create the thread is as follows:

ThreadStart activeThreadStart = new ThreadStart(dataConversion);
activeThread = new Thread(activeThreadStart);
activeThread.Start();

We have attempted to trap this error to no avail, even going so far as to
use the following:

CustomExceptionHandler eh = new CustomExceptionHandler();
Application.ThreadException += new
ThreadExceptionEventHandler(eh.OnThreadException);
Application.Run(new SummaryForm());

All target machines have framework 1.1 and MDAC 2.8. If anyone has seen
this problem, or can suggest a cause or cure, that would be great.

Michael


Nov 16 '05 #4
John - your first link completely explains the source of the problem and the
solution. A million thanks.

Michael
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Michael Lane <ar***@mailblocks.ca> wrote:
We have developed an application which performs a series of long tasks,
so
in order to keep the GUI responsive we do these tasks in a separate
thread.
When run from the development environment, or run as a standalone
application on any machine with VS 2003 installed, it is fine. On any
other
machine, a exception is generated at a seemingly random time during
execution. The message box simply says "Application has generated an
exception which cannot be handled."

If we do not launch these processes in a separate thread (i.e call the
method directly), the problem disappears. The very simply code we use the
create the thread is as follows:

ThreadStart activeThreadStart = new ThreadStart(dataConversion);
activeThread = new Thread(activeThreadStart);
activeThread.Start();

We have attempted to trap this error to no avail, even going so far as to
use the following:

CustomExceptionHandler eh = new CustomExceptionHandler();
Application.ThreadException += new
ThreadExceptionEventHandler(eh.OnThreadException);
Application.Run(new SummaryForm());

All target machines have framework 1.1 and MDAC 2.8. If anyone has seen
this
problem, or can suggest a cause or cure, that would be great.


Are you updating the UI from the other thread, by any chance? If so,
that's probably the problem.
See http://www.pobox.com/~skeet/csharp/t...winforms.shtml

Otherwise, could you post a short but complete program which
demonstrates the problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #5
Ok, I see Jon's article solved it.

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Michael Lane" <ar***@mailblocks.ca> wrote in message
news:ew**************@TK2MSFTNGP11.phx.gbl...
Thanks very much for taking the time to reply to my post.

The thread is doing data conversion tasks which basically consist of data
copying, shuffling and manipulating for the most part. Yes, I am updating
the GUI from within the worker thread - I update a label and a progress
bar. Is this a potential source of problems? Is there a workaround?

Michael

"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:ea**************@TK2MSFTNGP10.phx.gbl...
Hi Michael,

You are not accessing GUI controls from worker thread, do you?
What are you doing in worker thread?

--
Miha Markic [MVP C#] - RightHand .NET consulting & development
miha at rthand com
www.rthand.com

"Michael Lane" <ar***@mailblocks.ca> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
We have developed an application which performs a series of long tasks,
so in order to keep the GUI responsive we do these tasks in a separate
thread. When run from the development environment, or run as a
standalone application on any machine with VS 2003 installed, it is
fine. On any other machine, a exception is generated at a seemingly
random time during execution. The message box simply says "Application
has generated an exception which cannot be handled."

If we do not launch these processes in a separate thread (i.e call the
method directly), the problem disappears. The very simply code we use
the create the thread is as follows:

ThreadStart activeThreadStart = new ThreadStart(dataConversion);
activeThread = new Thread(activeThreadStart);
activeThread.Start();

We have attempted to trap this error to no avail, even going so far as
to use the following:

CustomExceptionHandler eh = new CustomExceptionHandler();
Application.ThreadException += new
ThreadExceptionEventHandler(eh.OnThreadException);
Application.Run(new SummaryForm());

All target machines have framework 1.1 and MDAC 2.8. If anyone has seen
this problem, or can suggest a cause or cure, that would be great.

Michael



Nov 16 '05 #6

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

Similar topics

8
by: John B | last post by:
ARGGGGGHH I have a database class instantiated with a Using statement, then a reader also instantiated with a using statement. If the command I use to populate the reader throws an exception, then...
7
by: SparkPlug | last post by:
Does anyone know why I might be getting an XmlSchemaException in App.config configured as below to use the UIP Application Block? I get the following error for every element, sub-element and...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
2
by: akameswaran | last post by:
Admittedly this problem causes no actual functional issues aside from an occasional error message when the program exits. The error is: Unhandled exception in thread started by Error in...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.