示例#1
0
        public void Connect(string hostIp, int hostPortNo, string charSet, string dbName, string user, string pwd, int commandTimeoutSec = 60)
        {
            if (Connection != null)
            {
                return;
            }


            string connStr = $"Server={hostIp};Port={hostPortNo};Uid={user};Pwd={pwd};";

            if (charSet != null)
            {
                connStr += $"CharSet={charSet};";
            }
            if (dbName != null)
            {
                connStr += $"Database={dbName};";
            }


            QPS        = new IntervalCounter(1000);
            Connection = new MySqlConnection(connStr);
            Connection.Open();


            /*using (DBCommand cmd = DBCommand.NewCommand(MySql))
             * {
             *  cmd.QueryNoReader("set transaction isolation level read uncommitted;");
             *  cmd.QueryNoReader("set session wait_timeout=604800;set session interactive_timeout=604800;");
             * }*/
        }
示例#2
0
        public void Connect(string host, string userId, string userPwd, string dbName)
        {
            if (Connection != null)
                return;

            QPS = new IntervalCounter("", 1000);
            Connection = new SqlConnection(string.Format("server={0};uid={1};pwd={2};database={3};", host, userId, userPwd, dbName));
            Connection.Open();
        }
示例#3
0
 public override void OnHarmonySpecial()
 {
     Harmony.IsSpiky_Aura = true;
     IntervalCounter ic = new IntervalCounter(TimeSpan.FromSeconds(PhysicsData1.SpikePowerLength));
     ic.IntervalTrigger += (s, e) =>
         {
             Harmony.IsSpiky_Aura = false;
         };
     World.Timers.AddTimerNextUpdate(ic, true);
 }
示例#4
0
        public void Connect(String host, String userId, String userPwd, String dbName)
        {
            if (Connection != null)
            {
                return;
            }


            QPS        = new IntervalCounter(1000);
            Connection = new SqlConnection(String.Format("server={0};uid={1};pwd={2};database={3};", host, userId, userPwd, dbName));
            Connection.Open();
        }
示例#5
0
        public void Connect(string hostIp, int hostPortNo, string charSet, string dbName, string user, string pwd, int commandTimeoutSec = 60)
        {
            if (Connection != null)
                return;

            QPS = new IntervalCounter(1000);
            Connection = new MySqlConnection(string.Format("Server={0};Port={1};CharSet={2};Database={3};Uid={4};Pwd={5};"
                                            , hostIp, hostPortNo, charSet, dbName, user, pwd));
            Connection.Open();

            /*using (DBCommand cmd = DBCommand.NewCommand(MySql))
            {
                cmd.QueryNoReader("set transaction isolation level read uncommitted;");
                cmd.QueryNoReader("set session wait_timeout=604800;set session interactive_timeout=604800;");
            }*/
        }
示例#6
0
        public void Connect(String hostIp, Int32 hostPortNo, String charSet, String dbName, String user, String pwd, Int32 commandTimeoutSec = 60)
        {
            if (Connection != null)
            {
                return;
            }


            QPS        = new IntervalCounter(1000);
            Connection = new MySqlConnection(String.Format("Server={0};Port={1};CharSet={2};Database={3};Uid={4};Pwd={5};"
                                                           , hostIp, hostPortNo, charSet, dbName, user, pwd));
            Connection.Open();


            /*using (DBCommand cmd = DBCommand.NewCommand(MySql))
             * {
             *  cmd.QueryNoReader("set transaction isolation level read uncommitted;");
             *  cmd.QueryNoReader("set session wait_timeout=604800;set session interactive_timeout=604800;");
             * }*/
        }
示例#7
0
    static void Main()
    {
        int interval;
        int divisor;

        try
        {
            // Prompt for the interval - the number to count up to.
            Console.Write ("Enter the interval (e.g. 100000000):  ");
            interval = int.Parse(Console.ReadLine());

            // Prompt for the divisor - the number that will be divided into
            // the counter. If the result is 0, a status message will be displayed.
            Console.Write ("Enter the divisor  (e.g. 10000000):   ");
            divisor = int.Parse(Console.ReadLine());

            // Create a new IntervalCounter object passing in the data from
            // the user.
            IntervalCounter ic = new IntervalCounter(interval, divisor);

            // Create the thread delegate giving it the target method to call.
            ThreadStart workerDelegate1 = new ThreadStart(ic.DisplayIntervals);

            // TODO: Step 1a - Create a second thread delegate.
            ThreadStart workerDelegate2 = new ThreadStart(ic.DisplayIntervals);

            // Create the thread object.
            Thread workerThread1 = new Thread(workerDelegate1);

            // TODO: Step 1b - Create a second thread object giving it the second delegate.
            Thread workerThread2 = new Thread(workerDelegate2);

            // Set the name of the threads.
            workerThread1.Name = "Worker Thread #1";

            // TODO: Step 1c - Set the name of the second thread.
            workerThread2.Name = "Worker Thread #2";

            // Start the thread.
            workerThread1.Start();

            // TODO: Step 1d - Start the second thread.
            workerThread2.Start();

            // Join the thread and wait until it is done.
            workerThread1.Join();

            // TODO: Step 1e - Join the second thread and wait until it is done.
            workerThread2.Join();
        }
        catch (Exception e)
        {
            Console.WriteLine ("\n\nERROR: Exception [ " + e.Message + " ] occurred.");
        }

        // Pause to view output.
        Console.Write("\n\nPress <ENTER> to end: ");
        Console.ReadLine();
    }
示例#8
0
    static void Main()
    {
        int interval;
        int divisor;

        try
        {
            // Prompt for the interval - the number to count up to.
            Console.Write ("Enter the interval (e.g. 100000000):  ");
            interval = int.Parse(Console.ReadLine());

            // Prompt for the divisor - the number that will be divided into
            // the counter. If the result is 0, a status message will be displayed.
            Console.Write ("Enter the divisor  (e.g. 10000000):   ");
            divisor = int.Parse(Console.ReadLine());

            // Create a new IntervalCounter object passing in the data from
            // the user.
            IntervalCounter ic = new IntervalCounter(interval, divisor);

            // Create the thread object. You can skip creating the delegate
            // object and simply provide the target method to the Thread's
            // constructor. The delegate object will be created by the runtime.
            Thread workerThread = new Thread(ic.DisplayIntervals);

            // Set the name of the thread.
            workerThread.Name = "Interval Counter Worker Thread";

            // Start the thread.
            workerThread.Start();

            // Join the thread and wait until it is done.
            workerThread.Join();
        }
        catch (Exception e)
        {
            Console.WriteLine ("\n\nERROR: Exception [ " + e.Message + " ] occurred.");
        }

        // Pause to view output.
        Console.Write("\n\nPress <ENTER> to end: ");
        Console.ReadLine();
    }
示例#9
0
        protected override void Reset()
        {
            ArtAssets.PlayerSprites[ZoomLevels.One][Jousters.Harmony].DrawArgs.Scale = V2.One;
            ArtAssets.PlayerSprites[ZoomLevels.One][Jousters.Dischord].DrawArgs.Scale = V2.One;

            for (int i = 0; i < PhysicsData1.NumbStartingBacteria; ++i)
                Blockers.Add(MakeRandomBacteria());

            Harmony.OnHurtEnemy += (s, e) =>
            {
                SoundAssets1.PlayRandomHiss();
            };
            Dischord.OnHurtEnemy += (s, e) =>
            {
                SoundAssets1.PlayRandomHiss();
            };

            //Start the timer loop.
            IntervalCounter bacteriaSpawn = new IntervalCounter(TimeSpan.FromSeconds(PhysicsData1.BacteriaAppearanceTime));
            bacteriaSpawn.IntervalTrigger += (s, e) =>
                {
                    Bacteria bactt = MakeRandomBacteria();
                    Blockers.Add(bactt);

                    IntervalCounter counter = new IntervalCounter(TimeSpan.FromSeconds(PhysicsData1.BacteriaLifeLength));
                    counter.IntervalTrigger += (s2, e2) =>
                        {
                            KillBlocker(bactt);
                        };
                    Timers.AddTimerNextUpdate(counter, true);
                };
            Timers.AddTimerNextUpdate(bacteriaSpawn, false);
        }