Click here to Skip to main content
15,913,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: Methods with generic value type parameters in C# Pin
gshen20-Jul-07 8:47
gshen20-Jul-07 8:47 
GeneralRe: Methods with generic value type parameters in C# Pin
Dave Kreskowiak20-Jul-07 9:01
mveDave Kreskowiak20-Jul-07 9:01 
GeneralRe: Methods with generic value type parameters in C# Pin
Kevin McFarlane20-Jul-07 9:02
Kevin McFarlane20-Jul-07 9:02 
GeneralRe: Methods with generic value type parameters in C# Pin
gshen20-Jul-07 9:10
gshen20-Jul-07 9:10 
GeneralRe: Methods with generic value type parameters in C# Pin
Dave Kreskowiak20-Jul-07 9:51
mveDave Kreskowiak20-Jul-07 9:51 
GeneralRe: Methods with generic value type parameters in C# Pin
Larantz21-Jul-07 9:51
Larantz21-Jul-07 9:51 
GeneralRe: Methods with generic value type parameters in C# Pin
Dave Kreskowiak22-Jul-07 4:21
mveDave Kreskowiak22-Jul-07 4:21 
QuestionDetecting when multiple BackgroundWorkers are finished Pin
dilucidate20-Jul-07 8:05
dilucidate20-Jul-07 8:05 
Hi, this is my first post on here so we'll see how it goes.

I am trying to write a method that uses a number of thread to populate an object and then return the object. The problem is that I never know when the threads are finished. I thought about having a counter and it will add when the thread finishes, and then have a Timer check every few seconds and see if the numbers match; however, the it is still a hack and I cannot return my object in the timer event. Any ideas?

public IApplicationPrivilegeCollection GetAllUserPrivileges(string userName)
        {
            Precondition.NotNullArgument(userName, "userName");

            IDatabaseInfoCollection databaseInfoCollection = _databaseInfoRepository.getAllDatabases();
            IApplicationPrivilegeCollection applicationPrivilegeCollection = new ApplicationPrivilegeCollection();
            int applicationCount = 0;
            //For each program get user priv information
            foreach (IDatabaseInfo databaseInfo in databaseInfoCollection)
            {
                //for each priv check if they have privs
                BackgroundWorker worker = new BackgroundWorker();
                IApplicationPrivilege list = new ApplicationPrivilege();

                worker.DoWork += delegate(object sender, DoWorkEventArgs e)
                                     {
                                         worker = sender as BackgroundWorker;
                                         list = GetUserPrivilege(userName, (IDatabaseInfo)e.Argument);
                                     }
                    ;
                worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
                                                 {
                                                     applicationPrivilegeCollection.Add(list);
                                                     applicationCount++;
                                                 };
                worker.RunWorkerAsync(databaseInfo);
            }

            //Timer timer = new Timer();
            //timer.Interval = 250;
            //timer.Elapsed += delegate
            //                     {
            //                         if(applicationCount == databaseInfoCollection.Count)
            //                         {
            //                             timer.Stop();
            //                             return;
            //                         }
            //                     };
            //timer.Start();

            return applicationPrivilegeCollection;
        }

AnswerRe: Detecting when multiple BackgroundWorkers are finished Pin
led mike20-Jul-07 8:23
led mike20-Jul-07 8:23 
GeneralRe: Detecting when multiple BackgroundWorkers are finished Pin
dilucidate20-Jul-07 8:48
dilucidate20-Jul-07 8:48 
GeneralRe: Detecting when multiple BackgroundWorkers are finished Pin
led mike23-Jul-07 5:02
led mike23-Jul-07 5:02 
QuestionFocusable Panel Pin
Sukhjinder_K20-Jul-07 7:14
Sukhjinder_K20-Jul-07 7:14 
AnswerRe: Focusable Panel Pin
Judah Gabriel Himango20-Jul-07 7:29
sponsorJudah Gabriel Himango20-Jul-07 7:29 
GeneralRe: Focusable Panel Pin
Sukhjinder_K20-Jul-07 7:39
Sukhjinder_K20-Jul-07 7:39 
QuestionSerialization of arrays Pin
Rudolf Jan20-Jul-07 7:05
Rudolf Jan20-Jul-07 7:05 
AnswerRe: Serialization of arrays Pin
led mike20-Jul-07 7:14
led mike20-Jul-07 7:14 
GeneralRe: Serialization of arrays Pin
Rudolf Jan23-Jul-07 2:56
Rudolf Jan23-Jul-07 2:56 
GeneralRe: Serialization of arrays Pin
Rudolf Jan23-Jul-07 8:03
Rudolf Jan23-Jul-07 8:03 
GeneralRe: Serialization of arrays Pin
led mike23-Jul-07 8:23
led mike23-Jul-07 8:23 
GeneralRe: Serialization of arrays Pin
Rudolf Jan5-Aug-07 10:07
Rudolf Jan5-Aug-07 10:07 
QuestionShowing form window above task bar. Pin
kaleem tarar20-Jul-07 6:48
kaleem tarar20-Jul-07 6:48 
QuestionHow to install an addin for Visual Studio .NET 2005 Pin
imagic20-Jul-07 6:35
imagic20-Jul-07 6:35 
AnswerRe: How to install an addin for Visual Studio .NET 2005 Pin
Judah Gabriel Himango20-Jul-07 7:31
sponsorJudah Gabriel Himango20-Jul-07 7:31 
GeneralRe: How to install an addin for Visual Studio .NET 2005 Pin
imagic20-Jul-07 18:53
imagic20-Jul-07 18:53 
GeneralRe: How to install an addin for Visual Studio .NET 2005 Pin
imagic20-Jul-07 22:49
imagic20-Jul-07 22:49 

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.