Esempio n. 1
0
        protected virtual async Task Connect()
        {
            if (this.isConnected)
            {
                return;
            }

            var tcs = new TaskCompletionSource <object>();

            Application.Context.StartService(new Intent(Application.Context, typeof(EstimoteSdk.Service.BeaconService)));
            var ready = new ServiceReadyCallbackImpl(() =>
            {
                Log.Debug(DEBUG_TAG, "successfully connected to estimote service");
                this.isConnected = true;
                tcs.TrySetResult(null);
            });

            this.beaconManager.Connect(ready);
            await tcs.Task;
        }
Esempio n. 2
0
        protected virtual async Task Connect()
        {
            await Task.Factory.StartNew(() => {
                this.locker.WaitOne();

                if (this.isConnected)
                {
                    Log.Debug(DEBUG_TAG, "already connected to estimote service");
                }
                else
                {
                    Application.Context.StartService(new Intent(Application.Context, typeof(EstimoteSdk.Service.BeaconService)));
                    var ready = new ServiceReadyCallbackImpl(() => {
                        Log.Debug(DEBUG_TAG, "successfully connected to estimote service");
                        this.isConnected = true;
                        this.locker.Set();
                    });
                    this.beaconManager.Connect(ready);
                }
            });

            await Task.Delay(300); // let android get its stuff together
        }
        protected virtual async Task Connect() {
            await Task.Factory.StartNew(() => {
                this.locker.WaitOne();

                if (this.isConnected)
                    Log.Debug(DEBUG_TAG, "already connected to estimote service");
                else {
                    Application.Context.StartService(new Intent(Application.Context, typeof(EstimoteSdk.Service.BeaconService)));
			        var ready = new ServiceReadyCallbackImpl(() => {
                        Log.Debug(DEBUG_TAG, "successfully connected to estimote service");
				        this.isConnected = true;
                        this.locker.Set();
			        });
    		        this.beaconManager.Connect(ready);
                }
            });
            await Task.Delay(300); // let android get its stuff together
        }