当前位置: 首页>>代码示例>>C#>>正文


C# System.Threading.Tasks.Task.Start方法代码示例

本文整理汇总了C#中System.Threading.Tasks.Task.Start方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Tasks.Task.Start方法的具体用法?C# System.Threading.Tasks.Task.Start怎么用?C# System.Threading.Tasks.Task.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Threading.Tasks.Task的用法示例。


在下文中一共展示了System.Threading.Tasks.Task.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateDB

        /// <summary>
        /// Create the initial database
        /// </summary>
        private void CreateDB()
        {
            var connection = new SqlCeConnection(this.path);

            try
            {
                var eng = new SqlCeEngine(this.path);
                var cleanup = new System.Threading.Tasks.Task(eng.Dispose);
                eng.CreateDatabase();
                cleanup.Start();
            }
            catch (Exception e)
            {
                EventLogging.WriteError(e);
            }

            connection.Open();
            var usersDB =
                new SqlCeCommand(
                    "CREATE TABLE Users_DB("
                    + "UserID int IDENTITY (100,1) NOT NULL UNIQUE, "
                    + "UserName nvarchar(128) NOT NULL UNIQUE, "
                    + "PassHash nvarchar(128) NOT NULL, "
                    + "Friends varbinary(5000), "
                    + "PRIMARY KEY (UserID));",
                    connection);
            usersDB.ExecuteNonQuery();
            usersDB.Dispose();
            connection.Dispose();
            connection.Close();
        }
开发者ID:novaksam,项目名称:CIS499_C-_IM_Package,代码行数:34,代码来源:DBInteract.cs

示例2: Main

        static public void Main()
        {
            Pubnub pubnub = new Pubnub(
                                       publishKey: "pub-c-d8635a25-b556-4267-84c4-a9db379cd66a",
                                       subscribeKey: "sub-c-e809ad42-8bd8-11e5-bf00-02ee2ddab7fe");

            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
                () =>
                pubnub.Subscribe<string>(
                channel: channel,
                userCallback: DisplaySubscribeReturnMessage,
                connectCallback: DisplaySubscribeConnectStatusMessage,
                errorCallback: DisplayErrorMessage)
            );
            t.Start();

            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                string msg = Console.ReadLine();
                pubnub.Publish<string>(
                    channel: channel,
                    message: msg,
                    userCallback: DisplayReturnMessage,
                    errorCallback: DisplayErrorMessage);
                Console.WriteLine("Message {0} sent.", msg);
            }
        }
开发者ID:NikitoG,项目名称:TelerikAcademyHomeworks,代码行数:28,代码来源:PubnubExample.cs

示例3: Run

        public void Run(string configuration, IResultHandler resultHandler)
        {
            Console.WriteLine("Doing work for: " + configuration);

            var t = new System.Threading.Tasks.Task(() => { resultHandler.OnSuccess(); });

            t.Start();
        }
开发者ID:Timxuhj,项目名称:redis.workflow,代码行数:8,代码来源:ThreadPoolTaskHandler.cs

示例4: ProcessTimer

		/// <summary>
		///		Procesa los datos
		/// </summary>
		private void ProcessTimer()
		{ // Detiene el temporizador
				objTimer.Stop();
			// Si se debe ejecutar, crea un hilo nuevo
				if (MustExecute())
					{ System.Threading.Tasks.Task objTaskCompiler = new System.Threading.Tasks.Task(() => CallProcess());

							// Arranca el hilo
								objTaskCompiler.Start();
					}
		}
开发者ID:jbautistam,项目名称:CopySolutionsVisualStudio,代码行数:14,代码来源:AbstractProcessScheduler.cs

示例5: Main

       public static void Main()
        {
            // Start the HTML5 Pubnub client
            Process.Start(@"..\..\index.html");

            System.Threading.Thread.Sleep(2000);

            PubnubAPI pubnub = new PubnubAPI(
                "pub-c-35648aec-f497-4d5b-ab3e-8d621ba3794c",               // PUBLISH_KEY
                "sub-c-fb346fbe-8d19-11e5-a7e4-0619f8945a4f",               // SUBSCRIBE_KEY
                "sec-c-M2JmNWIwODMtNDNhYi00MjBlLWI2ZTYtZjExNjA1OTU4ZDBj",   // SECRET_KEY
                true                                                        // SSL_ON?
            );

            string channel = "simple chat channel";

            // Publish a sample message to Pubnub
            List<object> publishResult = pubnub.Publish(channel, "Hello there!");

            Console.WriteLine(
                "Publish Success: " + publishResult[0] + "\n" +
                "Publish Info: " + publishResult[1]
            );

            // Show PubNub server time
            object serverTime = pubnub.Time();
            Console.WriteLine("Server Time: " + serverTime);

            // Subscribe for receiving messages (in a background task to avoid blocking)
            var task = new System.Threading.Tasks.Task(
                () =>
                pubnub.Subscribe(
                    channel,
                    delegate (object message)
                    {
                        Console.WriteLine("Received Message -> '" + message + "'");
                        return true;
                    }

                )
            );

            task.Start();

            // Read messages from the console and publish them to Pubnub
            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                var message = Console.ReadLine();
                pubnub.Publish(channel, message);
                Console.WriteLine("Message {0} sent.", message);
            }
        }
开发者ID:Vyara,项目名称:Telerik-Academy,代码行数:53,代码来源:PubNubStartup.cs

示例6: Service

        public Service(VerifyData data)
        {
            _Key = new object();
            _Data = data;
            _Soin = new SpinWait();

            _Proxy = new Proxy(new RemotingFactory());
            (_Proxy as IUpdatable).Launch();
            _ProxyUpdate = new Task(Service._UpdateProxy, new WeakReference<Proxy>(_Proxy));
            _ProxyUpdate.Start();

            _User = _Proxy.SpawnUser("1");
        }
开发者ID:jiowchern,项目名称:Regulus,代码行数:13,代码来源:Service.cs

示例7: Main

        private static void Main()
        {
            // Start the HTML5 Pubnub client
            Process.Start("..\\..\\PubNubClient.html");

            Thread.Sleep(2000);

            var pubNubApi = new PubNubApi(
                "pub-c-4a077e28-832a-4b58-aa75-2a551f0933ef",               // PUBLISH_KEY
                "sub-c-3a79639c-059e-11e3-8dc9-02ee2ddab7fe",               // SUBSCRIBE_KEY
                "sec-c-ZTAxYTk2ZGMtNzRiNi00ZTkwLTg4ZWEtOTMxOTk4NzAyNGIw",   // SECRET_KEY
                true                                                        // SSL_ON?
            );

            string channel = "chat-channel";

            // Publish a sample message to Pubnub
            List<object> publishResult = pubNubApi.Publish(channel, "Hello Pubnub!");
            Console.WriteLine(
                "Publish Success: " + publishResult[0].ToString() + "\n" +
                "Publish Info: " + publishResult[1]
            );

            // Show PubNub server time
            object serverTime = pubNubApi.Time();
            Console.WriteLine("Server Time: " + serverTime.ToString());

            // Subscribe for receiving messages (in a background task to avoid blocking)
            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
                () =>
                pubNubApi.Subscribe(
                    channel,
                    delegate(object message)
                    {
                        Console.WriteLine("Received Message -> '" + message + "'");
                        return true;
                    }
                )
            );
            t.Start();

            // Read messages from the console and publish them to PubNub
            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                string message = Console.ReadLine();
                pubNubApi.Publish(channel, message);
                Console.WriteLine("Message {0} sent.", message);
            }
        }
开发者ID:vic-alexiev,项目名称:CloudServices,代码行数:50,代码来源:PubNubSender.cs

示例8: Main

        static void Main()
        {
            // Start the HTML5 Pubnub client
            Process.Start("..\\..\\PubNub-HTML5-Client.html");

            //System.Threading.Thread.Sleep(2000);

            PubnubAPI pubnub = new PubnubAPI(
                "pub-c-a40489bf-98a7-40ff-87df-4af2f371d50a",               // PUBLISH_KEY
                "sub-c-68236eaa-8bb6-11e5-8b47-02ee2ddab7fe",               // SUBSCRIBE_KEY
                "sec-c-ZmVhNTE4NTgtYWRmYi00NGNjLWIzNjgtZjI1YTU2M2ZkMDU2",   // SECRET_KEY
                true                                                        // SSL_ON?
            );
            string channel = "demo-channel";

            // Publish a sample message to Pubnub
            List<object> publishResult = pubnub.Publish(channel, "Hello Pubnub!");
            Console.WriteLine(
                "Publish Success: " + publishResult[0].ToString() + "\n" +
                "Publish Info: " + publishResult[1]
            );

            // Show PubNub server time
            object serverTime = pubnub.Time();
            Console.WriteLine("Server Time: " + serverTime.ToString());

            // Subscribe for receiving messages (in a background task to avoid blocking)
            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
                () =>
                pubnub.Subscribe(
                    channel,
                    delegate (object message)
                    {
                        Console.WriteLine("Received Message -> '" + message + "'");
                        return true;
                    }
                )
            );
            t.Start();

            // Read messages from the console and publish them to Pubnub
            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                string msg = Console.ReadLine();
                pubnub.Publish(channel, msg);
                Console.WriteLine("Message {0} sent.", msg);
            }
        }
开发者ID:Boyan1912,项目名称:Web-Services-and-Cloud,代码行数:49,代码来源:Program.cs

示例9: Main

        /* 02. Implement a very simple chat application based on some message queue service:
            Users can send message into a common channel.
            Messages are displayed in the format {IP : message_text}.
            Use PubNub. Your application can be console, GUI or Web-based.*/
        static void Main()
        {
            Process.Start("..\\..\\PubNubChatDemo.html");

            System.Threading.Thread.Sleep(2000);

            PubnubAPI pubnub = new PubnubAPI(
                "pub-c-e485b33f-6d32-4410-9cb8-98c61a4a48df",               // PUBLISH_KEY
                "sub-c-44c8865e-0817-11e3-ab8d-02ee2ddab7fe",               // SUBSCRIBE_KEY
                "sec-c-NWQwNjFmY2EtNzljMy00MGU2LTk4YjYtMWQwZThmM2U1Mjcw",   // SECRET_KEY
                false                                                        // SSL_ON?
            );
            string channel = "secret-ninja-channel";

            // Publish a sample message to Pubnub
            List<object> publishResult = pubnub.Publish(channel, "Hello Pubnub!");
            Console.WriteLine(
                "Publish Success: " + publishResult[0].ToString() + "\n" +
                "Publish Info: " + publishResult[1]
            );

            // Show PubNub server time
            object serverTime = pubnub.Time();

            Console.WriteLine("Server Time: " + serverTime.ToString());

            // Subscribe for receiving messages (in a background task to avoid blocking)
            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
                () =>
                pubnub.Subscribe(
                    channel,
                    delegate(object message)
                    {
                        Console.WriteLine("Received Message -> '" + message + "'");
                        return true;
                    }
                )
            );
            t.Start();

            // Read messages from the console and publish them to Pubnub
            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                string msg = Console.ReadLine();
                pubnub.Publish(channel, msg);
                Console.WriteLine("Message {0} sent.", msg);
            }
        }
开发者ID:nkolarov,项目名称:telerik-academy,代码行数:53,代码来源:PubNubChatDemo.cs

示例10: Main

        internal static void Main(string[] args)
        {
            Process.Start("..\\..\\RecieverPage.html");

            System.Threading.Thread.Sleep(2000);

            PubnubAPI pubnub = new PubnubAPI(
                "pub-c-d9aadadf-abba-443c-a767-62023d43411a",               // PUBLISH_KEY
                "sub-c-102d0358-073f-11e3-916b-02ee2ddab7fe",               // SUBSCRIBE_KEY
                "sec-c-YmI4NDcxNzQtOWZhYi00MTRmLWI4ODktMDI2ZjViMjQyYzdj",   // SECRET_KEY
                false);

            string channel = "PublishApp";

            // Publish a sample message to Pubnub
            List<object> publishResult = pubnub.Publish(channel, "Hello Pubnub!");
            Console.WriteLine(
                "Publish Success: " + publishResult[0].ToString() + "\n" +
                "Publish Info: " + publishResult[1]);

            // Show PubNub server time
            object serverTime = pubnub.Time();
            Console.WriteLine("Server Time: " + serverTime.ToString());

            // Subscribe for receiving messages (in a background task to avoid blocking)
            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
                () =>
                pubnub.Subscribe(
                    channel,
                    delegate(object message)
                    {
                        Console.WriteLine("Received Message -> '" + message + "'");
                        return true;
                    }));

            t.Start();

            // Read messages from the console and publish them to Pubnub
            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                string msg = Console.ReadLine();
                pubnub.Publish(channel, msg);
                Console.WriteLine("Message {0} sent.", msg);
            }
        }
开发者ID:HansS,项目名称:TelerikAcademy-homework,代码行数:46,代码来源:Program.cs

示例11: Main

        static void Main(string[] args)
        {
            log("Server started.");

            Server.ConsoleIO.ConsoleCommand consoleIO = new ConsoleIO.ConsoleCommand(system);

            System.Action oAction = new System.Action(run);
            System.Threading.Tasks.Task oTask = new System.Threading.Tasks.Task(oAction);

            oTask.Start();

               while (system.run())
            {
                System.Threading.Thread.Sleep(5000);
            }

            log("Server closed");
        }
开发者ID:MRH4287,项目名称:GameServer,代码行数:18,代码来源:Program.cs

示例12: Main

        static void Main()
        {
            // Start the HTML5 Pubnub client
            Process.Start("..\\..\\PubnubClient.html");

            System.Threading.Thread.Sleep(2000);

            PubnubAPI pubnub = new PubnubAPI(PUBLISH_KEY, SUBSCRIBE_KEY, SECRET_KEY, true);
            string channel = "chat-channel";

            // Publish a sample message to Pubnub
            List<object> publishResult = pubnub.Publish(channel, "Hello Pubnub!");
            Console.WriteLine(
                "Publish Success: " + publishResult[0].ToString() + "\n" +
                "Publish Info: " + publishResult[1]
            );

            // Show PubNub server time
            object serverTime = pubnub.Time();
            Console.WriteLine("Server Time: " + serverTime.ToString());

            // Subscribe for receiving messages (in a background task to avoid blocking)
            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
                () =>
                pubnub.Subscribe(
                    channel,
                    delegate (object message)
                    {
                        Console.WriteLine("Received Message -> '" + message + "'");
                        return true;
                    }
                )
            );
            t.Start();

            // Read messages from the console and publish them to Pubnub
            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                string msg = Console.ReadLine();
                pubnub.Publish(channel, msg);
                Console.WriteLine("Message {0} sent.\n", msg);
            }
        }
开发者ID:darkyto,项目名称:Web-Services-and-Cloud,代码行数:44,代码来源:ChatStartup.cs

示例13: Main

        static void Main(string[] args)
        {
            var myIp = GetExternalIp();
            // Start the HTML5 Pubnub client
            Process.Start(@"..\..\..\PubNub-HTML5-Client.html");

            System.Threading.Thread.Sleep(2000);

            Pubnub pubnub = new Pubnub(
                "pub-c-4331b990-8629-4f47-9669-51f0e2ee9c9d",               // PUBLISH_KEY
                "sub-c-bfd2fbba-0428-11e3-91de-02ee2ddab7fe",               // SUBSCRIBE_KEY
                "sec-c-NDExYTBlYjUtM2QyYS00YTJiLWExNDItM2Y5NDQ2ZjA1N2Uy",   // SECRET_KEY
                "",                                                         // CIPHER_KEY
                true                                                        // SSL_ON?
            );
            string channel = "ninja-channel";

            // Publish a sample message to Pubnub
            pubnub.Publish<string>(channel, "", DisplayReturnMessage);

            // Show PubNub server time
            pubnub.Time<string>(DisplayReturnMessage);
            //Console.WriteLine("Server Time: " + serverTime.ToString());

            // Subscribe for receiving messages (in a background task to avoid blocking)
            System.Threading.Tasks.Task t = new System.Threading.Tasks.Task(
                () =>
                pubnub.Subscribe<string>(
                    channel,
                    DisplayReturnMessage,
                    DisplayConnectStatusMessage
                )
            );
            t.Start();

            // Read messages from the console and publish them to Pubnub
            while (true)
            {
                Console.Write("Enter a message to be sent to Pubnub: ");
                string msg = Console.ReadLine();
                pubnub.Publish<string>(channel, myIp + " : " + msg, DisplayReturnMessage);
                Console.WriteLine("Message {0} sent.", msg);
            }
        }
开发者ID:saykorz,项目名称:TelerikAkademy,代码行数:44,代码来源:Program.cs

示例14: btnMaster_Click

 private void btnMaster_Click(object sender, EventArgs e)
 {
     List<Form> SubForms = new List<Form>();
     //Action<Form, Form> AddForm = (v, f) => { v = f; SubForms.Add(v); };
     Action<Picasso.MakeForm, Picasso.AssignForm> NewForm =
         (Construct, AssignToVar) =>
         {
             Form f = Construct();
             SubForms.Add(f);
             this.AddOwnedForm(f);
             f.Owner = this;
             AssignToVar(f);
         };
     M = new Master(ImgPath, NewForm, this);
     //int ChildrenCount;
     Watch = new Stopwatch();
     Action A = M.GenerateChildren;
     System.Threading.Tasks.Task T = new System.Threading.Tasks.Task(A);
     //System.Threading.Thread Th = new System.Threading.Thread(new System.Threading.ThreadStart(A));
     Watch.Start();
     T.Start();
 }
开发者ID:scnerd,项目名称:Picasso,代码行数:22,代码来源:MainWindow.cs

示例15: CorrectCaseTableNames

 private void CorrectCaseTableNames(object sender, EventArgs e)
 {
     try
     {
         var task = new System.Threading.Tasks.Task(() =>
         {
             OutputPane.WriteMessageAndActivatePane("Correcting the case of table names...");
             var finder = new CorrectCaseTableFinder();
             finder.CorrectCaseAllTableNames();
             OutputPane.WriteMessageAndActivatePane("Correcting the case of table names...done");
         });
         
         task.Start();
         
         if (task.Exception != null)
             throw task.Exception;
     }
     catch (Exception ex)
     {
         OutputPane.WriteMessage("Error correcting table name case: {0}", ex.Message);
     }
 }
开发者ID:japj,项目名称:SSDT-DevPack,代码行数:22,代码来源:SSDTDevPack.VSPackagePackage.cs


注:本文中的System.Threading.Tasks.Task.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。