Click here to Skip to main content
16,004,927 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Two hashsets same values, different HashCodes? Pin
Luc Pattyn30-Dec-09 1:00
sitebuilderLuc Pattyn30-Dec-09 1:00 
GeneralRe: Two hashsets same values, different HashCodes? Pin
ThomasPep30-Dec-09 2:20
ThomasPep30-Dec-09 2:20 
GeneralRe: Two hashsets same values, different HashCodes? Pin
Luc Pattyn30-Dec-09 3:03
sitebuilderLuc Pattyn30-Dec-09 3:03 
GeneralRe: Two hashsets same values, different HashCodes? Pin
Gideon Engelberth30-Dec-09 13:22
Gideon Engelberth30-Dec-09 13:22 
GeneralRe: Two hashsets same values, different HashCodes? [modified] Pin
ThomasPep30-Dec-09 20:29
ThomasPep30-Dec-09 20:29 
QuestionHow to propagate an exception raised in a worker thread to the UI thread Pin
DanielDaMeda29-Dec-09 10:21
DanielDaMeda29-Dec-09 10:21 
AnswerRe: How to propagate an exception raised in a worker thread to the UI thread Pin
ProtoBytes29-Dec-09 11:13
ProtoBytes29-Dec-09 11:13 
AnswerRe: How to propagate an exception raised in a worker thread to the UI thread Pin
john_masen6-Jan-10 2:11
john_masen6-Jan-10 2:11 
hi daniel,
I've read your code and performed following test. looks you can not just throw your exception in the new thread. you can handle it in the worker thread and use delegate to process it in GUI thread.
The following is my test code. 2 buttons in one single form. "Button1" can cause the program crash. "Button2" success capture the error. Hope it helps.
public partial class Form1 : Form
   {
       public Form1()
       {
           InitializeComponent();
       }

       private void button1_Click(object sender, EventArgs e)
       {

           Thread t = new Thread(delegate()
           {
               DoWork();
           });

           try
           {
               t.Start();
           }
           catch (Exception ex)
           {
               commonExceptionHandler(ex);
           }
       }

       private void button2_Click(object sender, EventArgs e)
       {
           Thread t = new Thread(delegate()
           {
               try
               {
                   DoWork();
               }
               catch (Exception ex)
               {

                   commonExceptionHandler(ex);
               }
           });
           t.Start();
       }
       private void commonExceptionHandler(Exception ex)
       {
           if (this.InvokeRequired)
           {
               this.Invoke(new Action(() => commonExceptionHandler(ex)));
           }
           else
           {
               //your code here
               MessageBox.Show("[got it!] "+Environment.NewLine+ ex.ToString());
           }
       }

       private void DoWork()
       {
           throw new InvalidOperationException("this is test");
       }
   }

AnswerRe: How to propagate an exception raised in a worker thread to the UI thread Pin
David Skelly6-Jan-10 5:41
David Skelly6-Jan-10 5:41 
QuestionUsing SMTP client of .net in proxy connections to send email Pin
JayKhatri28-Dec-09 19:52
JayKhatri28-Dec-09 19:52 
AnswerRe: Using SMTP client of .net in proxy connections to send email Pin
Dave Kreskowiak30-Dec-09 7:01
mveDave Kreskowiak30-Dec-09 7:01 
QuestionCommunicating with servers by code Pin
khKamel28-Dec-09 8:06
khKamel28-Dec-09 8:06 
AnswerRe: Communicating with servers by code Pin
Abhinav S28-Dec-09 19:55
Abhinav S28-Dec-09 19:55 
GeneralRe: Communicating with servers by code Pin
khKamel29-Dec-09 0:46
khKamel29-Dec-09 0:46 
GeneralRe: Communicating with servers by code Pin
Abhinav S30-Dec-09 2:03
Abhinav S30-Dec-09 2:03 
QuestionDebgugging application with AsyncOperations Pin
Jeroen De Dauw27-Dec-09 9:33
Jeroen De Dauw27-Dec-09 9:33 
AnswerRe: Debgugging application with AsyncOperations Pin
Eddy Vluggen29-Dec-09 7:10
professionalEddy Vluggen29-Dec-09 7:10 
AnswerRe: Debgugging application with AsyncOperations Pin
Luc Pattyn29-Dec-09 7:18
sitebuilderLuc Pattyn29-Dec-09 7:18 
QuestionRegion question [modified] Pin
Steve5177127-Dec-09 0:09
Steve5177127-Dec-09 0:09 
AnswerRe: Region question Pin
Luc Pattyn27-Dec-09 0:42
sitebuilderLuc Pattyn27-Dec-09 0:42 
Generaltest Pin
amitsol26-Dec-09 19:41
amitsol26-Dec-09 19:41 
GeneralRe: test [failed] Pin
Mark Salsbery27-Dec-09 8:41
Mark Salsbery27-Dec-09 8:41 
GeneralRe: test Pin
Dave Kreskowiak30-Dec-09 6:57
mveDave Kreskowiak30-Dec-09 6:57 
Question.NET and COM Pin
transoft23-Dec-09 8:16
transoft23-Dec-09 8:16 
AnswerRe: .NET and COM Pin
Richard MacCutchan23-Dec-09 9:47
mveRichard MacCutchan23-Dec-09 9:47 

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.