Ejemplo n.º 1
0
        public void serverTcp()
        {
            try
            {
                listener = new TcpListener(IPAddress.Any, 4512);
                listener.Start();
            }
            catch (SocketException e) {
                Console.WriteLine(e.ErrorCode + " " + e.Message);
                Thread.CurrentThread.Abort();
            }


            try
            {
                while (true)
                {
                    Console.Write("Waiting for connection...");
                    TcpClient client = listener.AcceptTcpClient();

                    Console.WriteLine("Connection accepted.");
                    NetworkStream   ns  = client.GetStream();
                    ThreadWithState tws = new ThreadWithState(client, ns, this);
                    Thread          t   = new Thread(new ThreadStart(tws.manageConnection));
                    t.Start();
                }
            }
            catch (ThreadAbortException e)
            {
                listener.Stop();
            }
            catch (SocketException ignore) {
            }
        }
Ejemplo n.º 2
0
        public static void playInThread(int sample)
        {
            // Supply the state information required by the task.
            ThreadWithState tws = new ThreadWithState(0);
            // Create a thread to execute the task, and then
            // start the thread.
            Thread t = new Thread(new ThreadStart(tws.ThreadProc));


            // Seems to work because the play cursor is being moved in the
            // thread rather than being stoped and started
            if (aSound[sample].Status.Playing == true)
            {
                aSound[sample].Stop();
            }
            else
            {
                t.Start();
            }

            // If the sample is already playing and t.Start is called
            // mulltiple instances will be played at the same time.. iteresting effect


            //t.Join();
        }
Ejemplo n.º 3
0
        public void TestThreadPassingData()
        {
            Debug.WriteLine($"Hello from TestThreadPassingData() (Thread ID: {Thread.CurrentThread.ManagedThreadId})");

            // A lambda expression execution.
            new Thread(() =>
            {
                Debug.WriteLine($"Hello from another thread (Thread ID: {Thread.CurrentThread.ManagedThreadId})");
            }).Start();

            // Anonymous methods.
            new Thread(delegate()
            {
                Debug.WriteLine($"Hello from another thread (Thread ID: {Thread.CurrentThread.ManagedThreadId})");
            }).Start();

            // Pass an argument into Thread’s Start method (ParameterizedThreadStart delegate).
            Thread t = new Thread(Print);

            t.Start($"Hello from another thread (Thread ID: {Thread.CurrentThread.ManagedThreadId})");
            t.Join();

            // Use instance of ThreadWithState warpper.
            var tws = new ThreadWithState("Hello");

            t = new Thread(tws.ThreadProc);
            t.Start();
            t.Join();

            Debug.WriteLine($"End of main thread (Thread ID: {Thread.CurrentThread.ManagedThreadId})");
        }
Ejemplo n.º 4
0
        private static void ThreadingReturnSample()
        {
            ThreadWithState tws = new ThreadWithState("This report displays the number {0}.", 42,
                                                      new ExampleCallback(ResultCallback));
            Thread t = new Thread(new ThreadStart(tws.ThreadProc));

            t.Start();
            Console.WriteLine("Main thread does some work, then waits.");
            t.Join();
        }
Ejemplo n.º 5
0
        public static void Run()
        {
            ThreadWithState tws = new ThreadWithState(5, 7, PrintThreadResult);

            Thread t = new Thread(new ThreadStart(tws.ThreadProc));

            t.Start();
            t.Join();

            Console.ReadLine();
        }
Ejemplo n.º 6
0
    static void Main()
    {
        ThreadWithState tws = new ThreadWithState("Запускается фоновый поток...", 25, ResultCallback);

        Thread t = new Thread(new ThreadStart(tws.ThreadProc));

        t.Start();
        Console.WriteLine("Снова чёт происходит в мейне...");
        t.Join();
        Console.WriteLine("Мейн закончился!");
    }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            ThreadWithState thstate = new ThreadWithState("Welcome to Thread Class", 100, new ExampleCallback(ResultCallback));
            Thread          th      = new Thread(new ThreadStart(thstate.Threadproc));

            th.Start();
            Console.WriteLine("Main thread does some work, then waits.");
            th.Join(); //Block till main thread Ends
            Console.WriteLine(
                "Independent task has completed; main thread ends.");
        }
Ejemplo n.º 8
0
    public static void Main()
    {
        ThreadWithState tws = new ThreadWithState("Ответ на ваш вопрос: {0}.", 42);

        Thread t = new Thread(tws.ThreadProc);

        t.Start();
        Console.WriteLine("Чё-то делаем в мейне, а потом ждём...");
        t.Join();
        Console.WriteLine("Фоновый поток завершился... мейн тоже.");
    }
Ejemplo n.º 9
0
        private static void ThreadStateSample()
        {
            ThreadWithState tws = new ThreadWithState("This report displays the number {0}", 42,
                                                      new ExampleCallback(ResultCallback));

            Thread t = new Thread(new ThreadStart(tws.ThreadProc));

            t.Start();
            Console.WriteLine("Main thread does some work, then waits.");
            t.Join();
            Console.WriteLine("Independent task has completed; main thread ends.");
        }
Ejemplo n.º 10
0
    public static void Main()
    {
        ThreadWithState tws = new ThreadWithState(
            "This report displays the number {0}.", 42);
        Thread t = new Thread(new ThreadStart(tws.ThreadProc));

        t.Start();
        Console.WriteLine("Main thread does some work, then waits.");
        t.Join();
        Console.WriteLine(
            "Independent task has completed; main thread ends.");
    }
Ejemplo n.º 11
0
        private void searchModules(string query, List <object> extras)
        {
            ThreadWithState tws = new ThreadWithState(modules, query, extras, this);

            // Create a thread to execute the task, and then
            // start the thread.
            Thread t = new Thread(new ThreadStart(tws.ThreadProc));

            t.Start();
            //Console.WriteLine("Main thread does some work, then waits.");
            //t.Join();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// 上传文件到服务器(上传至文件服务器)
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="filecontent"></param>
        public static void UploadFileThread(string filename)
        {
            UploadConfig    upConfig    = UploadConfig.getInstance();
            string          path        = filename.Substring(0, filename.LastIndexOf('/'));
            string          linuxroot   = upConfig.linux_site.nginx_root;
            string          windowsroot = HttpContext.Current.Server.MapPath("~");
            ThreadWithState tws         = new ThreadWithState(filename, path, windowsroot, linuxroot);
            // 创建执行任务的线程,并执行
            Thread t = new Thread(new ThreadStart(tws.UploadFile));

            t.Start();
            //t.Join();
        }
Ejemplo n.º 13
0
    public static void Main()
    {
        // Supply the state information required by the task.
        ThreadWithState tws = new ThreadWithState(
            "This report displays the number {0}.", 42);

        // Create a thread to execute the task, and then
        // start the thread.
        Thread t = new Thread(new ThreadStart(tws.ThreadProc));

        t.Start();
        Console.WriteLine("Main thread does some work, then waits.");
        t.Join();
        Console.WriteLine(
            "Independent task has completed; main thread ends.");
    }
Ejemplo n.º 14
0
        /// <summary>
        /// Execute is part of the Microsoft.Build.Framework.ITask interface.
        /// When it's called, any input parameters have already been set on the task's properties.
        /// It returns true or false to indicate success or failure.
        /// </summary>
        public override bool Execute()
        {
            Console.WriteLine("Execute! Begin AsyncTask... writeline");
            Log.LogMessage(MessageImportance.High, "Execute! Begin AsyncTask... LogMessage");

            // parameterized async thread, see: https://docs.microsoft.com/en-us/dotnet/standard/threading/creating-threads-and-passing-data-at-start-time#passing-data-to-threads
            ThreadWithState tws = new ThreadWithState(Log);
            Thread          t   = new Thread(new ThreadStart(tws.ThreadProc));

            t.Start();

            Log.LogMessage(MessageImportance.High, "Waiting " + _WaitDuration.ToString() + "ms");
            Thread.Sleep(_WaitDuration);
            Log.LogMessage(MessageImportance.High, "Done waiting! ");

            return(!Log.HasLoggedErrors);
        }
Ejemplo n.º 15
0
    public static void Main()
    {
        // Supply the state information required by the task.
        ThreadWithState tws = new ThreadWithState(
            "This report displays the number {0}.",
            42,
            new ExampleCallback(ResultCallback)
            );

        Thread t = new Thread(new ThreadStart(tws.ThreadProc));

        t.Start();
        Console.WriteLine("Main thread does some work, then waits.");
        t.Join();
        Console.WriteLine(
            "Independent task has completed; main thread ends.");
    }
Ejemplo n.º 16
0
        public LoadingForm()
        {
            string path = System.IO.Path.Combine(Environment.GetFolderPath(
                                                     Environment.SpecialFolder.MyDoc‌​uments), "FREE-OSINT");

            if (Directory.Exists(path))
            {
                //Exists
            }
            else
            {
                System.IO.Directory.CreateDirectory(path);
            }
            ThreadWithState tws = new ThreadWithState(this);

            InitializeComponent();
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.CenterToScreen();
            Thread t = new Thread(new ThreadStart(tws.ThreadProc));

            t.Start();
        }
Ejemplo n.º 17
0
        public static void Main()
        {
            // Supply the state information required by the task.
            ThreadWithState tws = new ThreadWithState(
                "This report displays the number", 42);

            // Create a thread to execute the task, and then...

            Thread t = new Thread(new ThreadStart(tws.ThreadProc));

            // ...start the thread
            t.Start();

            Debug.WriteLine("Main thread does some work, then waits.");

            t.Join();

            Debug.WriteLine(
                "Independent task has completed; main thread ends.");

            Thread.Sleep(Timeout.Infinite);
        }
Ejemplo n.º 18
0
        public static void RunWeek6Classwork()
        {
            ThreadingReturnSample();

            ThreadingSample2();

            //The callback method must match the signature of the callback delegate
            void ResultCallback(int lineCount)
            {
                Console.WriteLine("Independent task printed {0} lines.", lineCount);
            }

            void ThreadingReturnSample()
            {
                ThreadWithState tws = new ThreadWithState("This report displays the number {0}.", 42,
                                                          new ExampleCallback(ResultCallback));
                Thread t = new Thread(new ThreadStart(tws.ThreadProc));

                t.Start();
                Console.WriteLine("Main thread does some work, then waits.");
                t.Join();
                Console.WriteLine("Independent task has completed; main thread ENDS.");
            }

            void ThreadingSample2()
            {
                //Calling constructo with value using Thread two ways
                ThreadingExample myExample = new ThreadingExample();
                Thread           thread    = new Thread(() => myExample.SimpleMethod(100));

                thread.Start();

                //or the older implementation
                //Thread secondThread = new Thread(myExample.DifferentMethod);
                //secondThread.Start("I see");
            }
        }
Ejemplo n.º 19
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(textBox2.Text))
                {
                    MessageBox.Show("唯一编码不能为空");
                    return;
                }
                int index = dataGridView1.CurrentRow.Index; //获取选中行的行号
                if (ygw.InsertOldBookInfo(dataGridView1.Rows[index].Cells[0].Value.ToString(), textBox2.Text, textBox3.Text))
                {
                    MessageBox.Show("添加成功");
                    textBox2.Text = "";
                }
                else
                {
                    MessageBox.Show("添加失败");
                    return;
                }

                //开始同步新的出售信息到喵校园主库
                ThreadWithState tws = new ThreadWithState(
                    textBox3.Text,
                    dataGridView1.Rows[index].Cells[0].Value.ToString()
                    );

                Thread t = new Thread(new ThreadStart(tws.ThreadProc));
                t.IsBackground = true;
                t.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show("请选择有效的行数!Msg=" + ex.Message);
            }
        }
Ejemplo n.º 20
0
        private void InitConfig()
        {
            //rtAGV_Control宣告
            DeliverData = new rtAGV_Control();
            ThreatPara = new ThreadWithState();
            GlobalVar.CurrentPosition = new NavigationInfo();

            //宣告使用到的Region數量
            DeliverData.tAGV_Cfg.tMapCfg.alRegionNum = 1;
            DeliverData.tAGV_Cfg.tMapCfg.Init();

            //宣告有幾個Region
            DeliverData.tAGV_Cfg.tMapCfg.alNodeNumLocal = new int[1];

            //Region裡面分別的節點數量
            DeliverData.tAGV_Cfg.tMapCfg.alNodeNumLocal[0] = 5;

            //宣告節點使用到的空間
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal = new rtAGV_MAP_node[1][];
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0] = new rtAGV_MAP_node[5];

            //節點座標資訊
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][0].tCoordinate.eX = 5000;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][0].tCoordinate.eY = -3500;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][0].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][0].tNodeId.lIndex = 0;

            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][1].tCoordinate.eX = 5000;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][1].tCoordinate.eY = -950;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][1].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][1].tNodeId.lIndex = 1;

            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][2].tCoordinate.eX = 17100;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][2].tCoordinate.eY = -950;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][2].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][2].tNodeId.lIndex = 2;

            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][3].tCoordinate.eX = 8400;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][3].tCoordinate.eY = -950;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][3].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][3].tNodeId.lIndex = 3;

            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][4].tCoordinate.eX = 11550;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][4].tCoordinate.eY = -950;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][4].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.tMapCfg.atNodeLocal[0][4].tNodeId.lIndex = 4;
            //11550

            //宣告貨物空間
            DeliverData.tAGV_Cfg.atWarehousingCfg = new rtWarehousingInfo[1][];
            DeliverData.tAGV_Cfg.atWarehousingCfg[0] = new rtWarehousingInfo[4];

            //貨物資訊
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].eHeight = 51;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].DistanceDepth = 4500;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].eHeight = 110;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].DistanceDepth = 4500;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].eHeight = 110;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].DistanceDepth = 4500;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].eHeight = 110;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].DistanceDepth = 4500;

            //貨物地標
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].tCoordinate.eX = 17050;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].tCoordinate.eY = 120;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].eDirection = 90;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].tCoordinate.eX = 8400;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].tCoordinate.eY = 120;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].eDirection = 90;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].tCoordinate.eX = 5000;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].tCoordinate.eY = -4000;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].eDirection = 90;

            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].tCoordinate.eX = 11550;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].tCoordinate.eY = 120;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].eDirection = 90;

            //貨物對應到的節點索引
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].tNodeId.lIndex = 2;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][0].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].tNodeId.lIndex = 3;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][1].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].tNodeId.lIndex = 0;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][2].tNodeId.lRegion = 0;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].tNodeId.lIndex = 4;
            DeliverData.tAGV_Cfg.atWarehousingCfg[0][3].tNodeId.lRegion = 0;

            //路徑權重宣告
            DeliverData.tAGV_Cfg.tMapCfg.alPathTableLocal = new int[1][];

            DeliverData.tAGV_Cfg.tMapCfg.alPathTableLocal[0] = new int[]
            {   0, 2550, 99999, 99999, 99999,
                2550, 0, 12080, 3400 , 6550,
                99999, 12080, 0, 8680, 5550,
                99999,  3400, 8680, 0, 3150,
                99999,  6550, 5550, 3150, 0
            };
        }
Ejemplo n.º 21
0
        //添加出售信息按钮
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb_isbn.Text))
            {
                MyOperation.MessageShow("请输入图书的ISBN号");
                tb_isbn.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_sellerid.Text))
            {
                MyOperation.MessageShow("请输入书主号");
                tb_sellerid.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_sellinfoid.Text))
            {
                MyOperation.MessageShow("请输入图书唯一ID");
                tb_sellinfoid.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_price.Text))
            {
                MyOperation.MessageShow("请输入出售价格");
                tb_price.Focus();
                return;
            }

            string    sql = string.Format("SELECT id,gbookid FROM tt_bookinfo WHERE ISBN = '{0}'", tb_isbn.Text);
            DataTable dt  = dbo.Selectinfo(sql);

            if (dt.Rows.Count == 0)
            {
                MyOperation.MessageShow("未找到该ISBN号的书籍,请首先在上方搜索对应信息");
                MyOperation.DebugPrint("未找到该ISBN号的书籍 " + sql, 3);
                return;
            }

            sql = string.Format("SELECT sellinfoid FROM tt_sellinfo WHERE sellinfoid = '{0}'", tb_sellinfoid.Text);
            DataTable dt1 = dbo.Selectinfo(sql);

            if (dt1.Rows.Count != 0)
            {
                MyOperation.MessageShow("已经存在该图书唯一ID【" + tb_sellinfoid.Text + "】,请更换后重试");
                return;
            }
            sql = string.Format("INSERT INTO tt_sellinfo (sellinfoid,sellerid,bookid,price,buyer,buytime,issold) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",
                                tb_sellinfoid.Text, tb_sellerid.Text, dt.Rows[0]["id"].ToString(), tb_price.Text, App.login_staffid, DateTime.Now.ToString(), "0");
            if (1 == dbo.AddDelUpdate(sql))
            {
                MyOperation.MessageShow("添加成功");
            }
            else
            {
                MyOperation.MessageShow("添加失败");
                MyOperation.DebugPrint("添加交易信息时发生错误", 3);
                return;
            }

            //开始同步新的出售信息到喵校园主库
            ThreadWithState tws = new ThreadWithState(
                dt.Rows[0]["gbookid"].ToString(),
                tb_price.Text,
                dt.Rows[0]["id"].ToString()
                );

            Thread t = new Thread(new ThreadStart(tws.ThreadProc));

            t.IsBackground = true;
            t.Start();
            //原来在添加成功的分支中,现在移到线程建立完毕
            tb_sellinfoid.Text = tb_price.Text = "";
            tb_isbn.Focus();
        }
        public override IEnumerable <GameInfo> GetGames()
        {
            System.IO.Directory.CreateDirectory(GetCachePath("icons"));

            List <GameInfo> result     = new List <GameInfo>();
            string          logintoken = LibrarySettings.LoginToken;

            if (string.Equals("", logintoken))
            {
                return(result);
            }

            CookieAwareWebClient cln = new CookieAwareWebClient();
            //cln.Headers.Add(HttpRequestHeader.Cookie,"_simpleauth_sess="+logintoken);
            //cln.Headers.Add(HttpRequestHeader.Cookie, "csrf_cookie="+secret);
            var           cacheFile    = GetCachePath("games.json");
            var           purchaseFile = GetCachePath("purchases.json");
            List <string> purchases    = new List <string>();

            if (!LibrarySettings.AlwaysScanEverything && System.IO.File.Exists(purchaseFile))
            {
                using (StreamReader r = new StreamReader(purchaseFile))
                {
                    string jsonx = r.ReadToEnd();

                    var Items = JsonConvert.DeserializeObject <JArray>(jsonx);
                    foreach (JValue item in Items)
                    {
                        purchases.Add(item.ToString());
                    }
                }
            }


            cln.CookieContainer.SetCookies(new Uri("https://www.humblebundle.com"), "_simpleauth_sess=" + logintoken + ";");

            string myjson = cln.DownloadString("https://www.humblebundle.com/api/v1/user/order");
            //logger.Info(myjson);
            JArray objects = null;

            try{
                objects = JArray.Parse(myjson);
            } catch (Exception e) {
                logger.Info(e.StackTrace);
                throw new Exception("Login Token Wrong, please reauthenticate");
            }
            // Dictionary<int,string> threads = new Dictionary<int,string>(objects.Count);
            Dictionary <Thread, ThreadWithState> threads = new Dictionary <Thread, ThreadWithState>(objects.Count);

            foreach (JObject root in objects)
            {
                foreach (KeyValuePair <String, JToken> app in root)
                {
                    if (!purchases.Contains(app.Value.ToString()))
                    {
                        logger.Info("new purchase id: " + app.Value.ToString());
                        purchases.Add(app.Value.ToString());
                        ThreadWithState tws = new ThreadWithState(this, logintoken, app.Value.ToString());
                        Thread          t   = new Thread(new ThreadStart(tws.ThreadProc));
                        t.Start();
                        threads.Add(t, tws);
                    }
                }
                //break;
            }


            string json = JsonConvert.SerializeObject(purchases.ToArray());

            System.IO.File.WriteAllText(purchaseFile, json);



            //System.IO.File.AppendAllText(cacheFile, "[\n", Encoding.UTF8);

            List <string> already = new List <string>();

            string filecontents = "{\r\n";

            if (System.IO.File.Exists(cacheFile))
            {
                json = System.IO.File.ReadAllText(cacheFile);
            }
            else
            {
                json = "{}";
            }


            Dictionary <string, object> values = JsonConvert.DeserializeObject <Dictionary <string, object> >(json, new JsonConverter[] { new MyConverter() });

            foreach (KeyValuePair <string, object> entry in values)
            {
                Dictionary <string, object> item;
                item = (Dictionary <string, object>)entry.Value;

                var output = JsonConvert.SerializeObject(item, Formatting.Indented);

                //already.Add(entry.Key);
                //logger.Info("xxxXXXxxx  "+output);
                already.Add(entry.Key);

                if (already.Count > 1)
                {
                    filecontents += ",\r\n\"" + entry.Key + "\" : " + output;
                }
                else
                {
                    filecontents += "\"" + entry.Key + "\" : " + output;
                }
            }

            foreach (KeyValuePair <Thread, ThreadWithState> entry in threads)
            {
                entry.Key.Join();
                foreach (KeyValuePair <string, HumbleGameData> pair in entry.Value.Values)
                {
                    if (!already.Contains(pair.Key))
                    {
                        already.Add(pair.Key);
                        result.Add(pair.Value.Info);
                        metadata[pair.Key] = pair.Value.Meta;
                        if (already.Count > 1)
                        {
                            filecontents += ",\r\n\"" + pair.Value.MachineName + "\" : " + pair.Value.Json;
                        }
                        else
                        {
                            filecontents += "\"" + pair.Value.MachineName + "\" : " + pair.Value.Json;
                        }
                    }
                }
            }
            //logger.Info(filecontents+"\r\n}");
            System.IO.File.WriteAllText(cacheFile, filecontents + "\r\n}", Encoding.UTF8);


            //Directory.CreateDirectory(cacheDir);


            return(result);
            //return GetGamesOffline();
        }