473,326 Members | 2,147 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,326 software developers and data experts.

Try / Catch and Async methods

In the System::Speech namespace there asychronous methods on both the SR and
TTS sides. For example, RecognizeAsync( ) and SpeakAsync( ). For the
purposes of this discussion, it isn't important what these methods do, but
how they do them. That is, upon executing these methods, they do not
necessarily complete what they are intended to do before the code execution
moves past them to the following instructions. When they are done they
typically will cause an Event to happen that notifies the program the
operation is done.

I have a case where the operation of such an asynchronous function is
causing a system exception error. Is it possibly to try-catch such an
exception? Will putting the asynchronous method do it, something like:

try
{
MethodAsynch();
}
:
:
catch(...)
{
//...
}

Will wrapping the entire application's execution do it:

try
{
main()
{
//all code, contains any asynch method calls
}

catch(...)
{
//...
}

Will both/neither of these methods work? Assuming it is possible, what is
the way typically used?

Thanx!

[==Peter==]

Oct 16 '07 #1
3 2785
On Tue, 16 Oct 2007 08:30:49 -0700, "Peter Oliphant"
<po*******@roundtripllc.comwrote:
>In the System::Speech namespace there asychronous methods on both the SR and
TTS sides. For example, RecognizeAsync( ) and SpeakAsync( ). For the
purposes of this discussion, it isn't important what these methods do, but
how they do them. That is, upon executing these methods, they do not
necessarily complete what they are intended to do before the code execution
moves past them to the following instructions. When they are done they
typically will cause an Event to happen that notifies the program the
operation is done.

I have a case where the operation of such an asynchronous function is
causing a system exception error. Is it possibly to try-catch such an
exception? Will putting the asynchronous method do it, something like:

try
{
MethodAsynch();
}
:
:
catch(...)
{
//...
}

Will wrapping the entire application's execution do it:

try
{
main()
{
//all code, contains any asynch method calls
}

catch(...)
{
//...
}

Will both/neither of these methods work? Assuming it is possible, what is
the way typically used?
The function that is executed asynchronously should do the try/catch. You
can write a wrapper function for this if need be.

--
Doug Harrison
Visual C++ MVP
Oct 16 '07 #2

"Peter Oliphant" <po*******@roundtripllc.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
In the System::Speech namespace there asychronous methods on both the SR
and TTS sides. For example, RecognizeAsync( ) and SpeakAsync( ). For the
purposes of this discussion, it isn't important what these methods do, but
how they do them. That is, upon executing these methods, they do not
necessarily complete what they are intended to do before the code
execution moves past them to the following instructions. When they are
done they typically will cause an Event to happen that notifies the
program the operation is done.

I have a case where the operation of such an asynchronous function is
causing a system exception error. Is it possibly to try-catch such an
exception? Will putting the asynchronous method do it, something like:

try
{
MethodAsynch();
}
:
:
catch(...)
{
//...
}

Will wrapping the entire application's execution do it:

try
{
main()
{
//all code, contains any asynch method calls
}

catch(...)
{
//...
}

Will both/neither of these methods work? Assuming it is possible, what is
the way typically used?
I would not expect either method to work.

Catch the exception in the debugger and find out what thread it appears on.
If it isn't a thread you created, I don't think you will be able to
interpose an exception handler.
>
Thanx!

[==Peter==]

Oct 16 '07 #3
I think this approach might work. I can't test it since the problem I had is
now gone:

main()
{
try
{
// application code
}
catch(...)
{
// process error
}
return 0 ;
}

[==Peter==]

"Ben Voigt [C++ MVP]" <rb*@nospam.nospamwrote in message
news:uS**************@TK2MSFTNGP02.phx.gbl...
>
"Peter Oliphant" <po*******@roundtripllc.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>In the System::Speech namespace there asychronous methods on both the SR
and TTS sides. For example, RecognizeAsync( ) and SpeakAsync( ). For the
purposes of this discussion, it isn't important what these methods do,
but how they do them. That is, upon executing these methods, they do not
necessarily complete what they are intended to do before the code
execution moves past them to the following instructions. When they are
done they typically will cause an Event to happen that notifies the
program the operation is done.

I have a case where the operation of such an asynchronous function is
causing a system exception error. Is it possibly to try-catch such an
exception? Will putting the asynchronous method do it, something like:

try
{
MethodAsynch();
}
:
:
catch(...)
{
//...
}

Will wrapping the entire application's execution do it:

try
{
main()
{
//all code, contains any asynch method calls
}

catch(...)
{
//...
}

Will both/neither of these methods work? Assuming it is possible, what is
the way typically used?

I would not expect either method to work.

Catch the exception in the debugger and find out what thread it appears
on. If it isn't a thread you created, I don't think you will be able to
interpose an exception handler.
>>
Thanx!

[==Peter==]

Oct 21 '07 #4

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

Similar topics

1
by: scott ocamb | last post by:
hello I have implemented a solution using async methods. There is one async method that can be invoked multiple times, ie there are multiple async "threads" running at a time. When these...
10
by: Shawn Meyer | last post by:
Hello - I am trying to write a class that has an async BeginX and EndX, plus the regular X syncronous method. Delegates seemed like the way to go, however, I still am having problems getting...
1
by: Simon Hart | last post by:
Hi, I thought I'd just open a thread in an attempt to get peoples feelers with regards to multithreading vs Async Web Service processing. Of course Web Services makes it easy to do Async...
6
by: Shak | last post by:
Hi all, Three questions really: 1) The async call to the networkstream's endread() (or even endxxx() in general) blocks. Async calls are made on the threadpool - aren't we advised not to...
11
by: atlaste | last post by:
Hi, In an attempt to create a full-blown webcrawler I've found myself writing a wrapper around the Socket class in an attempt to make it completely async, supporting timeouts and some scheduling...
10
by: Frankie | last post by:
It appears that System.Random would provide an acceptable means through which to generate a unique value used to identify multiple/concurrent asynchronous tasks. The usage of the value under...
10
by: ColoradoGeiger | last post by:
I have a fairly standard server application that I am using asynchronous socket calls to make connections, send and receive data, and all of that jazz. No blocking methods was my goal in writing...
1
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... There are a few questions wrapped up in this, but the main one is that the WebService.MyMethodAsync() methods that are automatically generated in the client code by VS 2005 don't seem to...
7
by: JackPot | last post by:
Actually, I'm interested in learning where the different types of exceptions are documented for a specific type of class, let us say for instance classes in the System.Net.Mail Namespace. Shouldn't...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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.