Click here to Skip to main content
16,015,900 members
Home / Discussions / C#
   

C#

 
QuestionDataset and DataGridView problem Pin
mertkan655-Sep-07 20:51
mertkan655-Sep-07 20:51 
AnswerRe: Dataset and DataGridView problem Pin
Frank Kerrigan5-Sep-07 23:04
Frank Kerrigan5-Sep-07 23:04 
GeneralRe: Dataset and DataGridView problem Pin
mertkan656-Sep-07 1:17
mertkan656-Sep-07 1:17 
QuestionVideo Chatting Pin
sandipan.neogi@gmail.com5-Sep-07 20:45
sandipan.neogi@gmail.com5-Sep-07 20:45 
Questioncontrol can not be parented in another thread Pin
Maddie from Dartford5-Sep-07 19:18
Maddie from Dartford5-Sep-07 19:18 
AnswerRe: control can not be parented in another thread Pin
Luc Pattyn6-Sep-07 3:27
sitebuilderLuc Pattyn6-Sep-07 3:27 
QuestionRMAN with C# Pin
WaiperWing755-Sep-07 18:13
WaiperWing755-Sep-07 18:13 
QuestionIs that Visual Studio feature for debugging? Pin
Michael Sync5-Sep-07 17:58
Michael Sync5-Sep-07 17:58 
I'm trying to handle the exception in my project. If the exception raised in same thread, I can handle it by using Try/Catch statement... but I'm not sure how to handle in different thread.....

I have one window application called "WindowsApplication1" and one class library called "ClassLibrary1". I added "ClassLibrary1" to "WindowsApplication1" as a reference.

In WindowApplication1, I have the following code.

delegate void action2();<br />
       private void button1_Click(object sender, EventArgs e)<br />
       {            <br />
           try<br />
           {<br />
               ClassLibrary1.Class1 obj = new ClassLibrary1.Class1 ();<br />
               action2 del = new action2 (obj.foo);<br />
               del.BeginInvoke( callback, del);<br />
           }<br />
           catch ( Exception ex )<br />
           {<br />
               MessageBox.Show (this,ex.Message);<br />
           }<br />
       }<br />
       private void callback(IAsyncResult a)<br />
       {<br />
           try<br />
           {<br />
               action2 a2 = (action2)a.AsyncState;<br />
               a2.EndInvoke (a);<br />
           }<br />
           catch (Exception ex)<br />
           {<br />
               MessageBox.Show (this, ex.Message);<br />
           }<br />
       }<br />


In ClassLibrary1.Class,

using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace ClassLibrary1 {<br />
    public class Class1 {<br />
        public void foo()<br />
        {<br />
            throw new Exception ("Why!!!");<br />
        }<br />
    }<br />
}<br />


When I run the application with "Control + F5" (without debugging), I got the messagebox ""Why!!!"" as the exception shown.

but when I run the application with "F5" (with debugging), I don't get the messagebox and Try/Catch statement from Form1 doens't work anymore..

So, How to handle the exception in different thread??

Any idea would be greatly appreciated. Let me know if you are not clear what I meant..

Thanks in advance.

Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)

If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. Smile | :)

QuestionGeneric forms call back? Pin
dino20945-Sep-07 14:06
dino20945-Sep-07 14:06 
AnswerRe: Generic forms call back? Pin
Steve Echols5-Sep-07 14:33
Steve Echols5-Sep-07 14:33 
GeneralRe: Generic forms call back? Pin
dino20945-Sep-07 15:17
dino20945-Sep-07 15:17 
QuestionC# Printer manipulation Pin
SBarnettAZ5-Sep-07 13:18
SBarnettAZ5-Sep-07 13:18 
Questionneed help for image alignment Pin
madokapeng5-Sep-07 12:56
madokapeng5-Sep-07 12:56 
QuestionGrid View Pin
seemamltn5-Sep-07 12:49
seemamltn5-Sep-07 12:49 
AnswerRe: Grid View Pin
Christian Graus5-Sep-07 15:06
protectorChristian Graus5-Sep-07 15:06 
AnswerRe: Grid View Pin
Frank Kerrigan5-Sep-07 23:07
Frank Kerrigan5-Sep-07 23:07 
QuestionOleDbDataReader Question - Urgent- Please Help!!! Pin
aro19815-Sep-07 11:25
aro19815-Sep-07 11:25 
AnswerRe: OleDbDataReader Question - Urgent- Please Help!!! Pin
Michael Potter5-Sep-07 11:40
Michael Potter5-Sep-07 11:40 
AnswerRe: OleDbDataReader Question - Urgent- Please Help!!! Pin
Pete O'Hanlon5-Sep-07 11:48
mvePete O'Hanlon5-Sep-07 11:48 
QuestionMultiple forms subscribing to the same event and data? Pin
basi00145-Sep-07 10:42
basi00145-Sep-07 10:42 
QuestionOleDbDataReader Question C# Pin
aro19815-Sep-07 10:26
aro19815-Sep-07 10:26 
QuestionThrowing events in unmanaged code Pin
Berlus5-Sep-07 10:12
Berlus5-Sep-07 10:12 
AnswerRe: Throwing events in unmanaged code Pin
Judah Gabriel Himango5-Sep-07 11:33
sponsorJudah Gabriel Himango5-Sep-07 11:33 
AnswerRe: Throwing events in unmanaged code Pin
Luc Pattyn5-Sep-07 11:48
sitebuilderLuc Pattyn5-Sep-07 11:48 
QuestionQuery Regarding SetPublicKeyToken Pin
Amar Chaudhary5-Sep-07 8:54
Amar Chaudhary5-Sep-07 8:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.