private void StartServer(IPAddress localIP, int localPort)
        {
            if (server == null)
            {
                server = new SimulationServer();
                server.Start(localIP, localPort);
            }

            if (serverThread == null)
            {
                serverThread = ThreadTool.Start(() =>
                {
                    while (true)
                    {
                        for (int i = 0; i < AreaCanvas1.PersonShapeList.Count; i++)
                        {
                            var ps = AreaCanvas1.PersonShapeList[i];
                            ps.SavePos();
                            var tPos  = ps.Pos;
                            var dbPos = tPos.ToDbModel();

                            Position pos = new Position();
                            pos.SetTime();
                            pos.SetProperty(dbPos);
                            server.Send(pos.GetText());
                        }

                        Thread.Sleep(250);
                    }
                });
            }
        }
        public void Logout()
        {
            ThreadTool.Close();

            Manager.ShowWindow(VMLogin);
            RequestClose();
        }
        public MainViewModel(IWindowManager manager,
                             SettingViewModel setting,
                             AboutViewModel about,
                             InfoViewModel albuminfo,
                             SearchViewModel search,
                             DllistViewModel dllist)
        {
            Manager   = manager;
            VMSetting = setting;
            VMAbout   = about;
            VMInfo    = albuminfo;
            VMSearch  = search;
            VMDllist  = dllist;
            ThreadTool.SetThreadNum(int.Parse(Config.ThreadNum()));

            UpdateThread = new Thread(ThreadUpdateFunc);
            UpdateThread.IsBackground = true;
            UpdateThread.Start();

            TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum()));

            ////test
            //CloudMusicAlbum album = Chinese.matchAlbum("Won't Cry", "Jay Chou");
            //string sName = Chinese.convertSongTitle("Won't Cry", album);
            //VMDllist.Convert();
            //return;
        }
        public void TestInsertPostions()
        {
            insertThread = ThreadTool.Start(() =>
            {
                List <Position> posList2 = new List <Position>();
                posList2.AddRange(Positions);
                Positions = new ConcurrentBag <Position>();

                foreach (Position position in posList2)
                {
                    List <Position> posList3 = new List <Position>();
                    posList3.Add(position);//模拟状态一个一个添加

                    if (InsertPostions(posList3))
                    {
                        WriteLogRight(GetLogText(string.Format("写入{0}条数据", posList3.Count)));
                    }
                    else
                    {
                        CloseBll();
                        Thread.Sleep(300);
                        WriteLogRight(GetLogText(string.Format("写入失败 当前有{0}条数据 error:{1}", posList2.Count, ErrorMessage)), true);
                    }
                }
            });
        }
Exemplo n.º 5
0
        public void Confirm()
        {
            Config.ThreadNum((ThreadNum + 1).ToString());
            Config.SearchNum(((SearchNum + 1) * 10).ToString());
            Config.OnlyM4a(OnlyM4a.ToString());
            Config.AddExplicitTag(AddExplicitTag.ToString());
            Config.SaveCovers(SaveCovers.ToString());
            Config.IncludeEP(IncludeEPSingle.ToString());
            Config.ToChinese(ToChinese.ToString());
            Config.CheckExist(CheckExist.ToString());
            Config.ArtistBeforeTitle(ArtistBeforeTitle.ToString());
            Config.AddHyphen(AddHyphen.ToString());
            Config.AddYear(AddYearIndex);
            Config.Quality(QualityList[SelectQualityIndex].ToLower());
            Config.Resolution(ResolutionList[SelectResolutionIndex]);
            Config.OutputDir(OutputDir);
            Config.UseTrackNumber(UseTrackNumber.ToString());
            Config.MaxFileName(CheckMaxName(MaxFileName));
            Config.MaxDirName(CheckMaxName(MaxDirName));
            Config.AddAlbumIDBeforeFolder(AddAlbumIDBeforeFolder.ToString());

            TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum()));
            ThreadTool.SetThreadNum(ThreadNum + 1);
            RequestClose();
        }
        public void Setting()
        {
            Manager.ShowDialog(VMSetting);
            string sValue = Config.ThreadNum();

            ThreadTool.SetThreadNum(int.Parse(sValue));
        }
Exemplo n.º 7
0
 public void TestThread(string shopName, DateTime shuffledTempDate, string dataSource)
 {
     ThreadTool.QueueUserWorkItem(ThreadDo);
     ThreadTool.QueueUserWorkItem(ThreadDo);
     ThreadTool.QueueUserWorkItem(ThreadDo);
     ThreadTool.QueueUserWorkItem(ThreadDo);
     ThreadTool.QueueUserWorkItem(ThreadDo);
 }
Exemplo n.º 8
0
        public void Can_CreateForm()
        {
            using (var form = new MyForm()) {
                form.Show();
                form.Update();

                ThreadTool.Sleep(5000);
            }
        }
 public void Confirm()
 {
     Config.ThreadNum((ThreadNum + 1).ToString());
     Config.OnlyM4a(OnlyM4a.ToString());
     Config.Quality(QualityList[SelectQualityIndex].ToLower());
     Config.Resolution(ResolutionList[SelectResolutionIndex]);
     Config.OutputDir(OutputDir);
     ThreadTool.SetThreadNum(ThreadNum + 1);
     RequestClose();
 }
Exemplo n.º 10
0
        public void Setting()
        {
            VMSetting.RefreshSetting();
            Manager.ShowDialog(VMSetting);
            string sValue = Config.ThreadNum();

            ThreadTool.SetThreadNum(int.Parse(sValue));

            SelectQualityIndex    = QualityList.IndexOf(Config.Quality().ToUpper());
            SelectResolutionIndex = ResolutionList.IndexOf(Config.Resolution().ToUpper());
        }
Exemplo n.º 11
0
 public void SendCmd(string cmd, int port, UDPArchorList list)
 {
     archorPort = port;
     ThreadTool.Start(() =>
     {
         foreach (var archor in list)
         {
             SendCmd(cmd, archor);
             Thread.Sleep(100);
         }
     });
 }
Exemplo n.º 12
0
        public bool isBusy = false;//没有这个标志位的话,很容易导致子线程间干扰

        public void StartInsertPositionTimer()
        {
            insertThread = ThreadTool.Start(() =>
            {
                while (true)
                {
                    Thread.Sleep(50);//300ms插入一次数据库
                    //todo:1.插入数据库时间写入配置文件,2.实时数据弄一个缓存,让客户端从缓存中取。
                    InsertPostions();
                }
            });
        }
        public void CallsDelegateAndReturnNonZeroTiming()
        {
            bool   called = false;
            double msecs  = With.OperationTimer(delegate {
                called = true;
                ThreadTool.Sleep(40);
            });

            // The only reliable way of testing this that I can think of.
            Assert.IsTrue(msecs > 0);
            Assert.IsTrue(called);

            Console.WriteLine("Operation elapsed time (msec): " + msecs);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Set Config And Close
        /// </summary>
        public void Confirm()
        {
            if (!AIGS.Helper.PathHelper.Mkdirs(OutputDir))
            {
                Errlabel = "Creat Output Path Err!";
                return;
            }

            Config.ThreadNum(ThreadNum.ToString());
            Config.Quality(QualityList[SelectQualityIndex].ToLower());
            Config.OutputDir(OutputDir);
            ThreadTool.SetThreadNum(ThreadNum);
            RequestClose();
        }
Exemplo n.º 15
0
        public void Confirm()
        {
            Config.ThreadNum((ThreadNum + 1).ToString());
            Config.SearchNum(((SearchNum + 1) * 10).ToString());
            Config.OnlyM4a(OnlyM4a.ToString());
            Config.ToChinese(ToChinese.ToString());
            Config.AddHyphen(AddHyphen.ToString());
            Config.Quality(QualityList[SelectQualityIndex].ToLower());
            Config.Resolution(ResolutionList[SelectResolutionIndex]);
            Config.OutputDir(OutputDir);

            TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum()));
            ThreadTool.SetThreadNum(ThreadNum + 1);
            RequestClose();
        }
Exemplo n.º 16
0
 private void InitTagPosition(int mockCount)
 {
     ThreadTool.Start(() =>
     {
         try
         {
             using (var positionBll = GetLocationBll())
             {
                 positionBll.InitTagPosition(mockCount);
             }
         }
         catch (Exception ex)
         {
             Log.Error("PositionEngineClient.InitTagPosition", ex);
         }
     });
 }
Exemplo n.º 17
0
        public MainViewModel(IWindowManager manager,
                             SettingViewModel setting,
                             AboutViewModel about,
                             InfoViewModel albuminfo,
                             SearchViewModel search)
        {
            Manager   = manager;
            VMSetting = setting;
            VMAbout   = about;
            VMInfo    = albuminfo;
            VMSearch  = search;
            ThreadTool.SetThreadNum(int.Parse(Config.ThreadNum()));

            Thread UpdateThread = new Thread(ThreadUpdateFunc);

            UpdateThread.IsBackground = true;
            UpdateThread.Start();
            return;
        }
Exemplo n.º 18
0
        public MainViewModel(IWindowManager manager,
                             SettingViewModel setting,
                             AboutViewModel about,
                             InfoViewModel albuminfo,
                             SearchViewModel search,
                             DllistViewModel dllist)
        {
            Manager   = manager;
            VMSetting = setting;
            VMAbout   = about;
            VMInfo    = albuminfo;
            VMSearch  = search;
            VMDllist  = dllist;
            ThreadTool.SetThreadNum(int.Parse(Config.ThreadNum()));

            UpdateThread = new Thread(ThreadUpdateFunc);
            UpdateThread.IsBackground = true;
            UpdateThread.Start();

            QualityList        = TidalTool.getQualityList();
            SelectQualityIndex = QualityList.IndexOf(Config.Quality().ToUpper());
            if (SelectQualityIndex < 0)
            {
                SelectQualityIndex = 0;
            }

            ResolutionList        = TidalTool.getResolutionList();
            SelectResolutionIndex = ResolutionList.IndexOf(Config.Resolution().ToUpper());
            if (SelectResolutionIndex < 0)
            {
                SelectResolutionIndex = 0;
            }

            TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum()));

            //test
            //VMDllist.Convert();
            //return;
        }
Exemplo n.º 19
0
        public void Confim()
        {
            Config.ThreadNum(ThreadNum.ToString());
            Config.SearchNum(SearchNum.ToString());
            Config.OnlyM4a(OnlyM4a.ToString());
            Config.AddExplicitTag(AddExplicitTag.ToString());
            Config.SaveCovers(SaveCovers.ToString());
            Config.IncludeEP(IncludeEPSingle.ToString());
            Config.CheckExist(CheckExist.ToString());
            Config.ArtistBeforeTitle(ArtistBeforeTitle.ToString());
            Config.AddHyphen(AddHyphen.ToString());
            Config.AddYear(AddYearIndex);
            Config.OutputDir(OutputDir);
            Config.UseTrackNumber(UseTrackNumber.ToString());
            Config.MaxFileName(MaxFileName.ToString());
            Config.MaxDirName(MaxDirName.ToString());
            Config.AddAlbumIDBeforeFolder(AddAlbumIDBeforeFolder.ToString());
            Config.ThemeIndex(ThemeIndex.ToString());

            TidalTool.SetSearchMaxNum(int.Parse(Config.SearchNum()));
            ThreadTool.SetThreadNum(ThreadNum);
            ChangeTheme(ThemeIndex);

            if (AccessToken.IsNotBlank())
            {
                if (TidalTool.loginByAccesstoken(AccessToken))
                {
                    Config.Accesstoken(AccessToken);
                }
                else
                {
                    Growl.Warning("Accesstoken is not valid!", "SettingsMsg");
                    return;
                }
            }
            Growl.Success("Refresh settings success!", "SettingsMsg");
        }
Exemplo n.º 20
0
 /// <summary>
 /// static constructor
 /// </summary>
 static RandomizerBase()
 {
     // _cof = new double[] { 76.1801, -86.5053, 24.0141, -1.23174, 0.00120865, -5.39524e-006 };
     _defaultRandomGenerator = ThreadTool.CreateRandom();
 }
Exemplo n.º 21
0
 public void WindowClose()
 {
     ThreadTool.Close();
     RequestClose();
 }
Exemplo n.º 22
0
 public void WindowClose()
 {
     ThreadTool.Close();
     ThreadHelper.Abort(UpdateThread);
     RequestClose();
 }