示例#1
0
文件: Status.cs 项目: magseet/AttiLA
 private void AwakeService()
 {
     lock (lockStatus)
     {
         var serviceStatus = ServiceStatus;
         if (serviceStatus == null || serviceStatus.ServiceState == ServiceStateCode.Idle)
         {
             // tracking start
             bool performed = false;
             for (var attempts = Properties.Settings.Default.ClientRetries + 1;
                  attempts > 0; attempts--)
             {
                 try
                 {
                     performed = _serviceClient.TrackingStart(CurrentContextId);
                     if (performed)
                     {
                         break;
                     }
                 }
                 catch { }
             }
             if (!performed)
             {
                 throw new StatusException(Properties.Resources.MsgTrackingStartFailure)
                       {
                           Code = StatusExceptionCode.ServiceFailure
                       };
             }
             for (var attempts = Properties.Settings.Default.ClientRetries + 1;
                  attempts > 0; attempts--)
             {
                 try
                 {
                     performed = _serviceClient.TrackingStop();
                     if (performed)
                     {
                         break;
                     }
                 }
                 catch { }
             }
             if (!performed)
             {
                 throw new StatusException(Properties.Resources.MsgTrackingStartFailure)
                       {
                           Code = StatusExceptionCode.ServiceFailure
                       };
             }
             NotifyIcon.ShowBalloonTip(Properties.Resources.PopupInfo,
                                       Properties.Resources.MsgServiceAwake, BalloonIcon.Info);
         }
     }
 }
示例#2
0
 private void btnTrackStop_Click(object sender, EventArgs e)
 {
     _serviceClient.TrackingStop();
 }