Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
D

DanielDaMeda

@DanielDaMeda
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to propagate an exception raised in a worker thread to the UI thread
    D DanielDaMeda

    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 unders

    .NET (Core and Framework) csharp help perl database oracle
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups