Exemple #1
0
        /// <summary>
        /// Initializes this handler's instance.
        /// </summary>
        public void Initialize()
        {
            JPEGCodec = GetEncoder(ImageFormat.Jpeg);

            encoder = Encoder.Compression;

            encoderParams = new EncoderParameters(1);

            encoderParams.Param [0] = new EncoderParameter(encoder, 40L);



            schedulerThread = new Thread(schedule);

            for (int i = 0; i < ThreadCount; i++)
            {
                var savingThread = new ThreadInformation(saveHandler);

                threadJobs.Add(savingThread.ThreadID, savingThread);
            }

            schedulerThread.Start();

            foreach (var thread in threadJobs)
            {
                //Thread.Sleep(3);

                thread.Value.Start();
            }
        }
Exemple #2
0
        private void InsertListItems(ThreadInformation information)
        {
            string[] row          = { information.ThreadId.ToString(), information.Sequence };
            var      listViewItem = new ListViewItem(row);

            listView1.Items.Insert(0, listViewItem);

            if (listView1.Items.Count >= 20)
            {
                listView1.Items.RemoveAt(19);
            }
        }
        public void InsertInformationToDb(ThreadInformation data)
        {
            data.DateTime = new DateTime(data.DateTime.Year, data.DateTime.Month, data.DateTime.Day,
                                         data.DateTime.Hour, data.DateTime.Minute, data.DateTime.Second, data.DateTime.Kind);

            cmd.CommandText = @"INSERT INTO Thread(Sequence, Thread_ID, DateT) Values(@FN, @LN, @GN)";
            cmd.Parameters.AddWithValue("@FN", data.Sequence);
            cmd.Parameters.AddWithValue("@LN", data.ThreadId);
            cmd.Parameters.Add(new OleDbParameter("@GN", data.DateTime));

            cmd.ExecuteNonQuery();
        }
Exemple #4
0
        private void ThreadProcedure(object o)
        {
            ThreadInformation info = o as ThreadInformation;

            try
            {
                info.SetThreadResult(Thread.CurrentThread, info.Container.ResolveAsync <IService>());
            }
            catch (System.Exception ex)
            {
                info.SetThreadResult(Thread.CurrentThread, ex);
            }
        }
Exemple #5
0
 private void Update()
 {
     if (threadQueue.Count > 0)
     {
         ThreadInformation TI = (ThreadInformation)threadQueue.Dequeue();
         TI.action(TI.vertices, TI.game, TI.posList);
         EndlessTerrain.startChunkCountSetup += 1;
         GameManager.instance.UpdateLoader();
         if (EndlessTerrain.startChunkCountSetup > EndlessTerrain.instance.chunkInviewDST + 3)
         {
             GameManager.instance.ReadyScene();
         }
     }
 }
Exemple #6
0
        public void PerThread_Factory_DifferentThreads()
        {
            Container.RegisterFactory <IService>((c, t, n) => new Service(), FactoryLifetime.PerThread);

            Thread t1 = new Thread(new ParameterizedThreadStart(ThreadProcedure));
            Thread t2 = new Thread(new ParameterizedThreadStart(ThreadProcedure));

            ThreadInformation info = new ThreadInformation(Container);

            t1.Start(info);
            t2.Start(info);
            t1.Join();
            t2.Join();

            var a = new List <IService>(info.ThreadResults.Values)[0];
            var b = new List <IService>(info.ThreadResults.Values)[1];

            Assert.AreNotSame(a, b);
        }
        public void PerThread_Type_DifferentThreads()
        {
            Container.RegisterType <IService, Service>(new PerThreadLifetimeManager());

            Thread t1 = new Thread(new ParameterizedThreadStart(ThreadProcedure));
            Thread t2 = new Thread(new ParameterizedThreadStart(ThreadProcedure));

            ThreadInformation info = new ThreadInformation(Container);

            t1.Start(info);
            t2.Start(info);
            t1.Join();
            t2.Join();

            var a = new List <IService>(info.ThreadResults.Values)[0];
            var b = new List <IService>(info.ThreadResults.Values)[1];

            Assert.AreNotSame(a, b);
        }
Exemple #8
0
        /// <summary>
        /// Initializes this handler's instance.
        /// </summary>
        public void Initialize()
        {
            schedulerThread = new Thread(schedule);

            for (int i = 0; i < ThreadCount; i++)
            {
                var savingThread = new ThreadInformation(threadedMemoryWriting);

                savingThread.SetPriorityHigh();

                threadJobs.Add(savingThread.ThreadID, savingThread);
            }

            //schedulerThread.Start ();

            foreach (var thread in threadJobs)
            {
                // Thread.Sleep (3);

                thread.Value.Start();
            }
        }
Exemple #9
0
        public async Task <HttpResponseMessage> Post()
        {
            if (WhiteList == null || Threads == null)
            {
                Initialize();
            }

            StringBuilder response = new StringBuilder();
            string        data     = await Request.Content.ReadAsStringAsync();

            JObject jEntity = JObject.Parse(data);
            string  type    = (string)jEntity["type"];

            switch (type)
            {
            case "confirmation":
                response.Append(Config.VerifyCode);
                break;

            case "message_new":
                ThreadInformation thread = new ThreadInformation(new Thread(Invoke));
                Threads.Add(thread);
                thread.Thr.Start(jEntity);
                break;
            }
            if (type != "confirmation")
            {
                response.Append("ok");
            }
            return(new HttpResponseMessage()
            {
                Content = new StringContent(
                    response.ToString(),
                    Encoding.UTF8,
                    "text/html")
            });
        }
        private void ThreadProcedure(object o)
        {
            ThreadInformation info = o as ThreadInformation;

            info.SetThreadResult(Thread.CurrentThread, info.Container.Resolve <IService>());
        }
Exemple #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Initializing API...");
            HF_API api = new HF_API("", "HF-Sharp");

            // Use this if you're running your program on a server or VPN.
            // The parameter passed to 'BypassCaptchaSystem' should be a 2Captcha API Key.

            /*Console.WriteLine("Bypassing captcha system...");
             * api.BypassCaptchaSystem("");*/

            Console.WriteLine("\nTesting GetVersion...");
            Console.WriteLine("Completed. Version #" + api.GetVersion());

            Console.WriteLine("\nTesting GetUserInformation...");
            UserInformation user = api.GetUserInformation(3241222);

            Console.WriteLine("username: "******"\nTesting GetCategoryInformation...");
            CategoryInformation category = api.GetCategoryInformation(151);

            Console.WriteLine("category name: " + category.Name);

            Console.WriteLine("\nTesting GetForumInformation...");
            ForumInformation forum = api.GetForumInformation(208);

            Console.WriteLine("forum name: " + forum.Name);

            Console.WriteLine("\nTesting GetThreadInformation...");
            ThreadInformation thread = api.GetThreadInformation(5665556);

            Console.WriteLine("thread name: " + thread.Subject);

            Console.WriteLine("\nTesting GetPostInformation...");
            PostInformation post = api.GetPostInformation(58564495);

            Console.WriteLine("post message: " + post.Message);

            Console.WriteLine("\nTesting GetPrivateMessageContainer...");
            PrivateMessageContainer privateMessageContainer = api.GetPrivateMessageContainer();

            Console.WriteLine("box information: " + privateMessageContainer.ContainerName + ", " + privateMessageContainer.PageInfo.TotalMessages + " messages");

            Console.WriteLine("\nTesting GetPrivateMessages...");
            List <PrivateMessageInformation> messages = api.GetPrivateMessages();

            Console.WriteLine("got messages: " + messages.Count + " total, first id: " + messages[0].ID);

            Console.WriteLine("\nTesting GetPrivateMessage...");
            PrivateMessage message = api.GetPrivateMessage(messages[0].ID);

            Console.WriteLine("got message: from " + message.FromUsername + ", to " + message.ToUsername + ", subject = " + message.Subject);

            Console.WriteLine("\nTesting GetGroupInformation...");
            GroupInformation group = api.GetGroupInformation(52);

            Console.WriteLine("group: " + group.Name + ", owner: " + group.Owner.Username);

            Console.ReadKey();
        }