private void OnOperationToDeviceWillComplete(IGarminDevice device, DeviceOperations operation)
        {
            m_TimeoutTimer.Stop();

            if (m_CancelDialog != null)
            {
                m_CancelDialog.Close();
                m_CancelDialog.Dispose();
                m_CancelDialog = null;
            }
        }
        private void OnTimeoutTimerTick(object sender, EventArgs e)
        {
            Logger.Instance.LogText("Operation timeout");
            m_TimeoutTimer.Stop();

            // Display a cancel dialog to the user
            if (m_CancelDialog == null)
            {
                GarminFitnessView pluginView = PluginMain.GetApplication().ActiveView as GarminFitnessView;

                m_CancelDialog = new CancelOperationDialog(new CancelOperationDelegate(CancelOperation));
                m_CancelDialog.Show();
            }
        }
        private void CancelOperation()
        {
            Logger.Instance.LogText("Cancelling operation");

            m_TimeoutTimer.Stop();
            if (m_CancelDialog != null)
            {
                m_CancelDialog.Close();
                m_CancelDialog.Dispose();
                m_CancelDialog = null;
            }

            if (CurrentTask != null)
            {
                if (CurrentTask.Type == BasicTask.TaskTypes.ExportWorkout ||
                    CurrentTask.Type == BasicTask.TaskTypes.ExportProfile)
                {
                    OperatingDevice.CancelWrite("Operation cancelled");
                }
                else if (CurrentTask.Type == BasicTask.TaskTypes.ImportWorkouts ||
                            CurrentTask.Type == BasicTask.TaskTypes.ImportProfile)
                {
                    OperatingDevice.CancelRead("Operation cancelled");
                }
                else
                {
                    CancelPendingTasks();
                    CompleteCurrentTask(false);
                }
            }
        }