/* connect to unit */ private async Task Connect(string portName, uint baudRate) { /* get page size */ // uint psize = uint.Parse(cbPSize.SelectedItem as string); uint psize = pageSize; /* create new programming interface object */ using (var uc = new STBoot()) { try { /* open device */ uc.Open(portName, baudRate); /* initialize communication */ //await uc.Initialize(); /* update the status */ //UpdateStatus(false, string.Format("Connected: Ver: {0}, PID: 0x{1:X4}", // uc.Version, uc.ProductID)); /* give some chance see the message */ //await Task.Delay(500); /* apply new message */ UpdateStatus(false, "Connecting..."); /* progress reporter */ var p = new Progress <STBootProgress>(UpdateProgress); /* connect */ await uc.Connect(); /* update the status */ //UpdateStatus(false, string.Format("Connected")); timer1.Enabled = true; bWrite.Enabled = false; WriteInProcess = false; connected = true; } catch { timer1.Enabled = false; bWrite.Enabled = false; bOpenFile.Enabled = false; WriteInProcess = false; connected = false; } finally { /* end communication */ uc.Close(); } } }