void _Start()
        {
            if (status == AdvertisementWatcherStatus.Started)
            {
                throw new InvalidOperationException("Watcher is already running");
            }
            if (status == AdvertisementWatcherStatus.Stopping)
            {
                throw new InvalidOperationException("Watcher is still stopping");
            }

            // following Windows API by setting Started status immediately
            status    = AdvertisementWatcherStatus.Started;
            stopError = AdvertisementWatcherError.None;

            StartAsync().ContinueWith(t => {
                if (t.Status != TaskStatus.RanToCompletion)
                {
                    status = AdvertisementWatcherStatus.Aborted;
                    // TODO: more specific errors based on exception
                    stopError = AdvertisementWatcherError.Unknown;
                    Stop();
                }
            });
        }
Exemplo n.º 2
0
 void OnStopped(AdvertisementWatcherError error)
 {
     Stopped?.Invoke(this, new AdvertisementWatcherStoppedEventArgs(error));
 }
 internal AdvertisementWatcherStoppedEventArgs(AdvertisementWatcherError error)
 {
     Error = error;
 }
Exemplo n.º 4
0
 public AdvertismentWatcherException(AdvertisementWatcherError error)
 {
     Error = error;
 }