コード例 #1
0
ファイル: RosConnection.cs プロジェクト: KIT-ISAS/iviz
        async Task Run()
        {
            try
            {
                while (!connectionTs.IsCancellationRequested)
                {
                    DateTime now = GameThread.Now;
                    if (KeepReconnecting &&
                        ConnectionState != ConnectionState.Connected &&
                        (now - lastConnectionTry).TotalMilliseconds > ConnectionRetryTimeInMs)
                    {
                        SetConnectionState(ConnectionState.Connecting);

                        bool connectionResult;

                        try
                        {
                            lastConnectionTry = now;
                            connectionResult  = await Connect();
                        }
                        catch (Exception e)
                        {
                            Logger.Error("Unexpected error in RosConnection.Connect", e);
                            continue;
                        }

                        SetConnectionState(connectionResult ? ConnectionState.Connected : ConnectionState.Disconnected);
                    }

                    await signal.WaitAsync(TaskWaitTimeInMs);
                    await ExecuteTasks().AwaitNoThrow(this);
                }

                SetConnectionState(ConnectionState.Disconnected);
            }
            catch (Exception e)
            {
                // shouldn't happen
                Logger.Internal("Left connection thread!");
                Logger.Internal("Error:", e);
                Logger.Error("XXX Left connection thread: ", e);
            }

            connectionTs.Cancel();
        }
コード例 #2
0
ファイル: LoadConfigDialogData.cs プロジェクト: KIT-ISAS/iviz
        void OnItemClicked(int index, int subIndex)
        {
            switch (subIndex)
            {
            case 0:
                ModuleListPanel.LoadStateConfiguration(files[index].FileName);
                Close();
                break;

            case 1:
                string filename = files[index].FullPath;
                try
                {
                    File.Delete(filename);
                }
                catch (Exception e)
                {
                    Logger.Internal("Error deleting config file", e);
                }

                ReadAllFiles();
                break;
            }
        }