Example #1
0
 private void ReadStep()
 {
     Debug.WriteLine("ReadStep: ENTER");
     try {
         int retry = 0;
         while (Crittercism.initialized &&
                (Crittercism.MessageQueue != null) &&
                (Crittercism.MessageQueue.Count > 0) &&
                (NetworkInterface.GetIsNetworkAvailable()) &&
                (retry < 3))
         {
             if (SendMessage())
             {
                 retry = 0;
             }
             else
             {
                 // TODO: Use System.Timers.Timer to generate an event
                 // 5 minutes from now, wait for it, then proceed.
                 retry++;
                 Debug.WriteLine("ReadStep: retry == " + retry);
             }
         }
         ;
         if (Crittercism.initialized)
         {
             // Opportune time to save Crittercism state.  Unable to make the MessageQueue
             // shorter either because SendMessage failed or MessageQueue has gone empty.
             // The readerThread will be going into a do nothing wait state after this.
             // (If Crittercism.initialized==false, we are shut down or shutting down, and
             // we must not call Crittercism.Save since this can lead to DEADLOCK.
             // Crittercism.Shutdown may have lock on Crittercism.lockObject, and is waiting
             // for our readerThread to exit.  Crittercism.Save would try to acquire
             // Crittercism.lockObject, but can't.)
             Crittercism.Save();
         }
         ;
     } catch (Exception ie) {
         Crittercism.LogInternalException(ie);
     }
     Debug.WriteLine("ReadStep: EXIT");
 }