private void btnTestConnect_Click(object sender, EventArgs e) { Port_Configured(); Cursor.Current = Cursors.WaitCursor; try { ModemCommunication.Open(); while (!ModemCommunication.IsConnected()) { Cursor.Current = Cursors.Default; if (MessageBox.Show(this, "No Phone Connectd.", "Connected Setup", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation) == DialogResult.Cancel) { ModemCommunication.Close(); return; } Cursor.Current = Cursors.WaitCursor; } ModemCommunication.Close(); } catch (Exception ex) { LogFile(ex.Message, e.ToString(), ((Control)sender).Name, this.FindForm().Name); MessageBox.Show(this, "Connection error:" + ex.Message, "Connection Setup", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } MessageBox.Show(this, "Successfully Connection to the phone.", "Connection Setup", MessageBoxButtons.OK, MessageBoxIcon.Information); btnConnect.Enabled = true; }
//private void Phone_Connection() //{ // Port_Configured(); // ModemCommunication.gsObj.PhoneConnected += new EventHandler(Comm_PhoneConnected); // Cursor.Current = Cursors.WaitCursor; // bool retry; // do // { // retry = false; // try // { // Cursor.Current = Cursors.WaitCursor; // ModemCommunication.Open(); // Cursor.Current = Cursors.Default; // } // catch (Exception) // { // Cursor.Current = Cursors.Default; // if (MessageBox.Show(this, "Unable to open the port.", "Error", // MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning) == DialogResult.Retry) // retry = true; // else // { // Close(); // return; // } // } // } // while (retry); //} private void Phone_Connection() { Port_Configured(); ModemCommunication.gsObj.PhoneConnected += new EventHandler(Comm_PhoneConnected); bool retry; ModemCommunication.Open(); //do //{ // retry = false; // try // { // } // catch (Exception) // { // retry = true; // } //} //while (retry); }