コード例 #1
0
ファイル: MasterThread.cs プロジェクト: alunfes/FlyerTrading
        public async static void startMasterThread()
        {
            SystemFlg.setMasterFlg(true);
            start_dt = new DateTime();
            start_dt = DateTime.Now;

            FlyerAPI2.startFlyerAPIMonitoring();

            while (SystemFlg.getMasterFlg())
            {
                await Task.Run(async() =>
                {
                    Form1.Form1Instance.Invoke((Action)(() =>
                    {
                        Form1.Form1Instance.setLabel10("system time elapsed (min)=" + Math.Round((DateTime.Now - start_dt).TotalMinutes, 2));
                    }));
                    await Task.Delay(100);
                    return(0);
                });
            }
        }
コード例 #2
0
ファイル: FlyerAPI2.cs プロジェクト: alunfes/FlyerTrading
        public static async Task <string> startFlyerAPIMonitoring()
        {
            setApiAccessProhibition(false);
            num_private_minit = new List <long>();
            num_public_minit  = new List <long>();
            int num = 0;

            while (SystemFlg.getMasterFlg())
            {
                await Task.Run(async() =>
                {
                    num_public_minit.Add(num_public_called);
                    num_private_minit.Add(num_private_called);

                    if (num_public_minit.Count > 60 && num_private_minit.Count > 60)
                    {
                        if ((num_private_called - num_private_minit[0]) > 150 || (num_public_called + num_private_called - num_public_minit[0] - num_private_minit[0]) > 450)
                        {
                            setApiAccessProhibition(true);
                            //Form1.Form1Instance.Invoke((Action)(() => { Form1.Form1Instance.setLabel7("API Access Prohibited"); }));
                        }
                        else
                        {
                            setApiAccessProhibition(false);
                        }
                        num_private_minit.RemoveAt(0);
                        num_public_minit.RemoveAt(0);
                    }
                    Form1.Form1Instance.Invoke((Action)(() =>
                    {
                        Form1.Form1Instance.setLabel8("num private api acecss in a min=" + (num_private_called - num_private_minit[0]).ToString());
                        Form1.Form1Instance.setLabel9("num public api acecss in a min=" + (num_public_called - num_public_minit[0]).ToString());
                    }));
                    await Task.Delay(1000);
                    return(0);
                });
            }
            return("completed");
        }