Click here to Skip to main content
15,917,951 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Regular Expression Help Pin
Paul Selormey30-Dec-09 22:22
Paul Selormey30-Dec-09 22:22 
QuestionTwo hashsets same values, different HashCodes? Pin
ThomasPep29-Dec-09 20:32
ThomasPep29-Dec-09 20:32 
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 
Hi all,

Hopefully this is the right thread for this question. I was quite uncertain to whether it was a .NET question or a C# question. However, I could see more thread related questions under the c# subject.
Well, I am new to the c# and the .net platform. I wonder if some kind soul could help me with my question. I am trying to develop a monitoring application that will be able to monitor all servers and Oracle databases on a network. I am using SQLITE for the local database and perl to act as the agent that keeps checking things out. For the front end, (The Configuration Assistant tool) I am using C#.

I often need to connect to Oracle Databases from my UI thread. I am avoiding to lock the UI by executing the DML under a second thread as follows:

try
{
   foreach (ListViewItem monitoredDatabases in monitoredDatabasesListView.Items)
   }
      String[] connectionResults = new String[10];
      Thread testOracleConnection = new Thread(delegate()
         try
         {
            // Invoke a method of another class that catches Oracle errors and re-throw the exception.

         }
         catch (OracleException) // CATCH inside thread 1
         {
            // If the testOracleConnection has raised an exception, I would like to re-throw the exception
            // so that the outer CATCH statement will deal with this.
            throw; // This causes the entire application to crash
            // However, I can clearly see that the code definitelly gets here
         }
      });
      testOracleConnection.Start();
      while (testOracleConnection.IsAlive)
      {
         Application.DoEvents();
         Thread.Sleep(1);
      }
   }
catch (Exception) CATCH on thread 0
{
   // The code never gets here when an OracleException was caught and re-thrown on above catch statement.
   progressInfoForm.Close();
   Cursor = Cursors.Default;
   return (false);
}


As you can see on the above code, the exception never gets to the CATCH statement on thread 0 and causes the entire application to crash.
What I want to do here is have one single place to restore all the normal behaviour of the form once it has encountered an exception. Eg, within the CATCH statement of the thread 0 (UI), I then reset the Cursor style, close the progress bar form and return with the correct status to the calling method.

It would be great if someone could actually show me how I could solve this problem by changing the code snipped above so that I can try it out and definitelly understand the solution.

Thank you very much.
Daniel
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 
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 

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.