Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Threading and VM
Message
De
27/07/2011 09:13:55
 
 
À
27/07/2011 08:30:19
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Versions des environnements
Environment:
C# 3.0
OS:
Windows XP SP2
Database:
Oracle
Application:
Desktop
Divers
Thread ID:
01519054
Message ID:
01519312
Vues:
31
>>
>>Wasn't my code :-}
>>TBH I didn't weigh up the pros and cons but it looked as if either could work.....
>
>
>Yep, it was mine. I know there is some room here to do this a bit different and the next time out it will get revisited. However now it works perfect and for some reason only needed to be slowed down. This is the part that is a bit puzzling. Apparently in VS with the debugger attached it runs just slow enough to be fine, but outside running the exe it gets missed. It isn't the value that is changing and causing the problem. The value changes to "LoginReady" and is logged; never changes, but the while loop never breaks out.. slowing it down a half second fixes it. I don't understand why really.

Still sounds a bit risky to me - and a AutoResetEvent is simple to implement. e.g: Main Thread:
private static AutoResetEvent StartupStatusChanged = new AutoResetEvent(false);
//Then when you want to notify the thread to carry on:
StartupStatusChanged.Set();
Then your DoWork could be something like:
            StartupStatusChanged.WaitOne();
            switch (StartupWorkerStatus)
            {
                case BackgroundWorkerStatus.LoginReady:
                    {
                        //Elided
                        break;
                    }
                case BackgroundWorkerStatus.Failed:
                    {
                        break;
                    }
                    //etc
            }
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform