.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Threading >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Async Component thread

Posted By:Karthikeyan Anbarasan       Posted Date: January 02, 2011    Points: 15    Category: Threading    URL: http://www.dotnetspark.com  

Async Component Thread
 

using System;
using System.Threading;

namespace Demo
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Main thread: {0}", Thread.CurrentThread.ManagedThreadId);

            AsyncComponent comp = new AsyncComponent();
            comp.LongTaskCompleted += Comp_LongTaskCompleted;

            comp.LongTaskAsync("Input details", 33);

            Console.ReadLine();
        }

        static void Comp_LongTaskCompleted(object sender, LongTaskCompletedEventArgs e)
        {
            Console.WriteLine("completed result: {0}, thread: {1}", e.Output, Thread.CurrentThread.ManagedThreadId);
        }
    }
}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend