McCarthy

McCarthy

  • NA
  • 17
  • 0

Howto? Making objects 'global' in scope using static.

May 3 2005 5:34 PM
I tried to search for this, but the search function seems to 404 at the moment, so pardon me if this has been discussed before. C# is my first forray into an OO language, but it's been a breeze compared to using C/C++ it's simply very easy to pick up and has been great (especially in v2.0) in implimenting threading etc... My problem: I have one method that gets called by a menu option, say "Open"... this opens a file using openfiledialog, when that is done I make sure that there is a file(s) in the .Filenames property and for each, I open an odbc connect to that file and do some work in the backgroun using backgroundworker. First, I need to let the method that runs in the background know what file(s) I opened in the "Open" method, then after the background method finishes I need it to return the datatable it opens to the "Continue" method of the program that gets called when the background task completes (I needed to put the odbc connection in the background, as I am with other tasks like it, because it prevents the UI from drawing of course if it had run in a single thread). I tried to store my openfile dialog object by using a custom class that creates a new sort of holder object, but this disapears when you exit the method that creates it... I'm experimenting with static, but any help would be much appreciated. Thanks, Michael McCarthy.

Answers (3)