Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / October 2007

Tip: Looking for answers? Try searching our database.

Try / Catch and Async methods

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Oliphant - 16 Oct 2007 16:30 GMT
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==]
Doug Harrison [MVP] - 16 Oct 2007 17:23 GMT
>In the System::Speech namespace there asychronous methods on both the SR and
>TTS sides. For example, RecognizeAsync( ) and SpeakAsync( ). For the
[quoted text clipped - 35 lines]
>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.

Signature

Doug Harrison
Visual C++ MVP

Ben Voigt [C++ MVP] - 16 Oct 2007 17:39 GMT
> In the System::Speech namespace there asychronous methods on both the SR
> and TTS sides. For example, RecognizeAsync( ) and SpeakAsync( ). For the
[quoted text clipped - 35 lines]
> 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==]
Peter Oliphant - 21 Oct 2007 03:37 GMT
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==]

>> In the System::Speech namespace there asychronous methods on both the SR
>> and TTS sides. For example, RecognizeAsync( ) and SpeakAsync( ). For the
[quoted text clipped - 45 lines]
>>
>> [==Peter==]

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.