Ejemplo n.º 1
0
        /// <summary>
        /// Attempts to begin sending stats to the server. Will throw an IllegalStateException if the syncher is already
        /// busy.
        /// </summary>
        public virtual void BeginSendStats(Dictionary <StatBase, int> par1Map)
        {
            if (IsBusy)
            {
                throw new InvalidOperationException("Can't save stats while StatsSyncher is busy!");
            }
            else
            {
                Field_27427_l = 100;
                IsBusy        = true;

                Action statSyncerSend = () =>
                {
                    try
                    {
                        StatsSyncher.Func_27412_a(this, par1Map, StatsSyncher.GetUnsentDataFile(this), StatsSyncher.GetUnsentTempFile(this), StatsSyncher.GetUnsentOldFile(this));
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception.ToString());
                        Console.Write(exception.StackTrace);
                    }
                    finally
                    {
                        StatsSyncher.SetBusy(this, false);
                    }
                };

                new Thread(new ThreadStart(statSyncerSend)).Start();
                return;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Attempts to begin receiving stats from the server. Will throw an IllegalStateException if the syncher is already
        /// busy.
        /// </summary>
        public virtual void BeginReceiveStats()
        {
            if (IsBusy)
            {
                throw new InvalidOperationException("Can't get stats from server while StatsSyncher is busy!");
            }
            else
            {
                Field_27427_l = 100;
                IsBusy        = true;

                Action statSyncherReceive = () =>
                {
                    try
                    {
                        if (StatsSyncher.Func_27422_a(this) != null)
                        {
                            StatsSyncher.Func_27412_a(this, StatsSyncher.Func_27422_a(this), StatsSyncher.Func_27423_b(this), StatsSyncher.Func_27411_c(this), StatsSyncher.Func_27413_d(this));
                        }
                        else if (File.Exists(StatsSyncher.Func_27423_b(this)))
                        {
                            StatsSyncher.Func_27421_a(this, StatsSyncher.Func_27409_a(this, StatsSyncher.Func_27423_b(this), StatsSyncher.Func_27411_c(this), StatsSyncher.Func_27413_d(this)));
                        }
                    }
                    catch (Exception exception)
                    {
                        Console.WriteLine(exception.ToString());
                        Console.Write(exception.StackTrace);
                    }
                    finally
                    {
                        StatsSyncher.SetBusy(this, false);
                    }
                };

                new Thread(new ThreadStart(statSyncherReceive)).Start();
                return;
            }
        }