private void ServiceDropped(IProvider sender, ServiceDroppedEventArgs args)
 {
     //Task mytask = Task.Run(() =>
     //{
     if (args != null)
     {
         ReleaseServiceComObject(args.Service);
     }
     //});
 }
Exemplo n.º 2
0
        private void AlljoynServiceDropped(IProvider sender, ServiceDroppedEventArgs args)
        {
            Utils.LogLine("Urządzenie " + args.Service.AboutData.DeviceName + " zostało odłączone.");

            LightbulbDevice droppedItem = Lightbulbs.Where(deviceItem => deviceItem.DeviceId == args.Service.AboutData.DeviceId).First();

            Lightbulbs.Remove(droppedItem);

            if (Lightbulbs.Count == 0)
            {
                NotifyServiceDown("IsAllJoynEnabled");
            }
        }
Exemplo n.º 3
0
        private async void ServiceDropped(IProvider sender, ServiceDroppedEventArgs args)
        {
            var name    = args.Service.AboutData?.DeviceName;
            var id      = args.Service.AboutData?.DeviceId;
            var appName = args.Service.AboutData?.AppName;

            if (appName == "Guybrush Station")
            {
                lock (Context.Current.Locks["Global"])
                {
                    var device  = Context.Current.Devices.FirstOrDefault(x => x.Title == name);
                    var reading = Context.Current.Readings.FirstOrDefault(x => x.Title == name);
                    if (device != null)
                    {
                        lock (Context.Current.Locks["Devices"])
                        {
                            if (device != null)
                            {
                                Context.Current.Devices.Remove(device);
                            }
                        }
                    }
                    else if (reading != null)
                    {
                        lock (Context.Current.Locks["Readings"])
                        {
                            var reader = Context.Current.Readings.FirstOrDefault(x => x.Title == name);
                            if (reader != null)
                            {
                                Context.Current.Readings.Remove(reader);
                            }
                        }
                    }
                    else if (name == "Guybrush Smart Home")
                    {
                        lock (Context.Current.Locks["Conditions"])
                        {
                            Context.Current.ConditionManager.Disconnect();
                        }
                    }
                }
                System.Diagnostics.Debug.WriteLine($"Lost device '{name}' : ID = {id}");
            }
        }