Exemplo n.º 1
0
        /// <summary>
        /// Starts this database
        /// </summary>
        public void Start()
        {
            // Create sqlite connection
            Connection = new SqliteConnection($"Data Source={DatabaseFile}");

            // Open sqlite connection
            Connection.Open();

            // Begin the write thread
            WriteThread.Start();
        }
Exemplo n.º 2
0
        // Starts this peer's associated threads
        internal void Start()
        {
            // Begin reading
            Read();

            // Begin writing
            WriteThread.Start();

            // Invoke peer connected callback
            Server.OnPeerConnected?.Invoke(this, EventArgs.Empty);
        }
Exemplo n.º 3
0
 protected void RestartWriteThread()
 {
     if (writeThread == null)
     {
         writeThread = new WriteThread(this);
         writeThread.Start();
         while (!writeThread.IsAlive)
         {
         }                                // Busy waiting
     }
 }
Exemplo n.º 4
0
 protected void RestartWriteThread()
 {
     if (writeThread == null)
     {
         writeThread = new WriteThread(this);
         writeThread.Start();
         while (!writeThread.IsAlive)
         {
         }                                // Busy waiting
         Log.Info("UsbSerialDevice", "Write Thread started.");
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Starts this instance.
        /// </summary>
        public void Start()
        {
            if (ReadThread != null)
            {
                ReadThread.Start();
            }

            if (WriteThread != null)
            {
                WriteThread.Start();
            }

            Running = true;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 备份文件线程
        /// </summary>
        void BackUpRun()
        {
            int count = 0;

            while (true)
            {
                GetBackUpItems(out count);
                if (count < 0)
                {
                    WriteState("连接失败!");
                    Thread.Sleep(1000);
                }
                else
                {
                    break;
                }
            }
            if (count > MemchcheCount)
            {
                WriteState("Memcache 已经有数据" + count + "条,大于设置恢复的条数" + MemchcheCount + "条,当前不需要更新!");
            }
            else
            {
                if (System.IO.Directory.Exists(recoverPath))
                {
                    if (System.IO.Directory.Exists(recoverPath))
                    {
                        string[] dirs    = Directory.GetDirectories(recoverPath);
                        string[] servers = (string[])serverList.ToArray(typeof(string));
                        //遍历本地文件,写入memcache
                        WriteThread wt = null;
                        foreach (string path in dirs)
                        {
                            wt            = new WriteThread(path, new Help(0, 1, 0, true));
                            wt.frm        = this;
                            wt.serverList = servers;
                            dicWirte.Add(path, wt);
                            wt.Start();
                        }
                    }
                }
                else
                {
                    return;
                }
            }
        }
Exemplo n.º 7
0
        private void FinishConnect(IAsyncResult result)
        {
            try
            {
                var beginClient = (TcpClient)result.AsyncState;
                if (beginClient == null)
                {
                    Close();
                    return;
                }
                beginClient.EndConnect(result);
                if (beginClient.Connected)
                {
                    // 启动读取和写入线程。
                    _readThread = new ReadThread(this, beginClient, _msgQueue);
                    _readThread.Start();

                    _writeThread = new WriteThread(this, beginClient, _msgQueue);
                    _writeThread.Start();

                    // 已经连接上。
                    Status  = SocketStatus.Connected;
                    _client = beginClient;
                }
                else
                {
                    // 未连接成功,关闭当前连接。
                    Close();
                }
            }
            catch (Exception e)
            {
                MyLog.ErrorAsync(Tag, string.Format("end connect error: {0}\n{1}", e.Message, e.StackTrace));
                Close();
            }
        }