Esempio n. 1
0
 public Task <IDeviceListener> GetDeviceListener()
 {
     return(this.deviceListener.Map(d => Task.FromResult(d))
            .GetOrElse(
                async() =>
     {
         using (await this.initializationLock.LockAsync())
         {
             return await this.deviceListener.Map(d => Task.FromResult(d))
             .GetOrElse(
                 async() =>
             {
                 IDeviceListener dl = await this.connectionProvider.GetDeviceListenerAsync(this.identity);
                 var deviceProxy = new DeviceProxy(this, this.identity);
                 dl.BindDeviceProxy(deviceProxy);
                 this.deviceListener = Option.Some(dl);
                 return dl;
             });
         }
     }));
 }
 public Task <IDeviceListener> GetDeviceListener()
 {
     return(this.deviceListener.Map(d => Task.FromResult(d))
            .GetOrElse(
                async() =>
     {
         using (await this.initializationLock.LockAsync())
         {
             return await this.deviceListener.Map(d => Task.FromResult(d))
             .GetOrElse(
                 async() =>
             {
                 // TODO: Implement plug and play for AMQP
                 IDeviceListener dl = await this.connectionProvider.GetDeviceListenerAsync(this.identity, Option.None <string>());
                 var deviceProxy = new DeviceProxy(this, this.identity);
                 dl.BindDeviceProxy(deviceProxy);
                 this.deviceListener = Option.Some(dl);
                 Events.InitializedDeviceListener(this.identity);
                 return dl;
             });
         }
     }));
 }