public async Task SearchDevices()
 {
     await Task.Run(() => {
         Bitalino.DevInfo[] devs          = Bitalino.find();
         EventSearchDeviceHandler handler = EnconteredDevices;
         if (handler != null)
         {
             handler(devs);
         }
     });
 }
        // Backgroundworker events
        private void bw_scannbluetooth_DoWork(object sender, DoWorkEventArgs e)
        {
            // search for bluetooth devices
            Bitalino.DevInfo[] BTLdevice = Bitalino.find();

            // add all found bloutooth devices to combobox
            foreach (Bitalino.DevInfo d in BTLdevice)
            {
                IDList.Add(d.macAddr);
                names.Add(d.name);
            }
        }
Пример #3
0
        public event EventSearchDeviceHandler EncontrarDispositivos;//evento

        public async Task SearchDevices()
        {
            await Task.Run(() => {
                Bitalino.DevInfo[] devs          = Bitalino.find();
                EventSearchDeviceHandler handler = EncontrarDispositivos;
                if (handler != null)
                {
                    handler(devs);
                }
            });//o metodo devolve uma tarefa, como é um async task vai estar dentro do 'await'

            // os '()' são uma função e o que está dentro dos '{}' é a solução(call back) dessa função
        }
        private void ShowDevices()
        {
            Bitalino.DevInfo[] devices = Bitalino.find();

            foreach (Bitalino.DevInfo d in devices)
            {
                string[] nameCheck = d.name.Split('-');

                if (nameCheck.Length > 0 && nameCheck[0] == "BITalino")
                {
                    BlinoDeviceList.Items.Add(d.macAddr + "-" + d.name);
                }
            }
        }