Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to count the numbers of pages from printer using ASP.NET With C# Pin
Pankaj Tak7-Jun-13 19:13
Pankaj Tak7-Jun-13 19:13 
GeneralRe: How to count the numbers of pages from printer using ASP.NET With C# Pin
Dave Kreskowiak8-Jun-13 4:23
mveDave Kreskowiak8-Jun-13 4:23 
Questionnested switch Pin
MKS Khalid18-May-13 11:47
MKS Khalid18-May-13 11:47 
AnswerRe: nested switch Pin
Richard MacCutchan18-May-13 21:16
mveRichard MacCutchan18-May-13 21:16 
AnswerRe: nested switch Pin
Eddy Vluggen19-May-13 2:14
professionalEddy Vluggen19-May-13 2:14 
AnswerRe: nested switch Pin
Sadhish T19-May-13 5:51
Sadhish T19-May-13 5:51 
GeneralRe: nested switch Pin
Dave Kreskowiak19-May-13 7:38
mveDave Kreskowiak19-May-13 7:38 
QuestionDifference between Thread, ThreadPool & BackgroundWorker c# Pin
Tridip Bhattacharjee18-May-13 8:34
professionalTridip Bhattacharjee18-May-13 8:34 
i many time call method with the help of thread like

static void Main( string[] args )
{
Thread t = new Thread( MyFunction );
t.Start();
}

static void MyFunction()
{
//code goes here
}

and some time i use ThreadPool class also like

System.Threading.ThreadPool.QueueUserWorkItem(delegate {
MyFunction();
}, null);

but i do not understand what is the difference between calling any method with the help of thread class or ThreadPool class

so i am looking a good discussion about what is the difference between Thread & ThreadPool class.also need to know when we should use Thread class to call a method and when ThreadPool class to call any method ? if possible discuss also with sample code with sample situation.

another very important question is that if i start multiple thread then my application performance will become low or bad ? if yes then tell me why...?

now also tell me what is BackgroundWorker class and how it is different from Thread & ThreadPool class. how far i heard that BackgroundWorker class also create a separate thread to run any method. so please discuss how it is different from Thread & ThreadPool class and when one should go for BackgroundWorker class.

here is small sample code of BackgroundWorker

private void button1_Click(object sender, EventArgs e)
{
BackgroundWorker bw = new BackgroundWorker();

// this allows our worker to report progress during work
bw.WorkerReportsProgress = true;

// what to do in the background thread
bw.DoWork += new DoWorkEventHandler(
delegate(object o, DoWorkEventArgs args)
{
BackgroundWorker b = o as BackgroundWorker;

// do some simple processing for 10 seconds
for (int i = 1; i <= 10; i++)
{
// report the progress in percent
b.ReportProgress(i * 10);
Thread.Sleep(1000);
}

});

// what to do when progress changed (update the progress bar for example)
bw.ProgressChanged += new ProgressChangedEventHandler(
delegate(object o, ProgressChangedEventArgs args)
{
label1.Text = string.Format("{0}% Completed", args.ProgressPercentage);
});

// what to do when worker completes its task (notify the user)
bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(
delegate(object o, RunWorkerCompletedEventArgs args)
{
label1.Text = "Finished!";
});

bw.RunWorkerAsync();
}
tbhattacharjee

AnswerRe: Difference between Thread, ThreadPool & BackgroundWorker c# Pin
Eddy Vluggen18-May-13 8:51
professionalEddy Vluggen18-May-13 8:51 
AnswerRe: Difference between Thread, ThreadPool & BackgroundWorker c# Pin
Dave Kreskowiak19-May-13 5:01
mveDave Kreskowiak19-May-13 5:01 
AnswerRe: Difference between Thread, ThreadPool & BackgroundWorker c# Pin
Abhinav S19-May-13 7:03
Abhinav S19-May-13 7:03 
QuestionMinidumps. Pin
Septimus Hedgehog18-May-13 8:08
Septimus Hedgehog18-May-13 8:08 
AnswerRe: Minidumps. Pin
Eddy Vluggen18-May-13 8:44
professionalEddy Vluggen18-May-13 8:44 
GeneralRe: Minidumps. Pin
Septimus Hedgehog18-May-13 9:14
Septimus Hedgehog18-May-13 9:14 
QuestionSome Basic Help About A Modification In a Script! Pin
Jesús Frías18-May-13 6:17
Jesús Frías18-May-13 6:17 
AnswerRe: Some Basic Help About A Modification In a Script! Pin
Dave Kreskowiak18-May-13 7:53
mveDave Kreskowiak18-May-13 7:53 
AnswerRe: Some Basic Help About A Modification In a Script! Pin
Calvijn18-May-13 10:55
Calvijn18-May-13 10:55 
Questionc@# Pin
MKS Khalid18-May-13 5:56
MKS Khalid18-May-13 5:56 
AnswerRe: c@# Pin
OriginalGriff18-May-13 6:00
mveOriginalGriff18-May-13 6:00 
Questionc# Thumbnail Viewer Pin
Dinesh Salunke17-May-13 18:39
Dinesh Salunke17-May-13 18:39 
AnswerRe: c# Thumbnail Viewer Pin
BillWoodruff17-May-13 20:42
professionalBillWoodruff17-May-13 20:42 
GeneralRe: c# Thumbnail Viewer Pin
Dinesh Salunke18-May-13 5:44
Dinesh Salunke18-May-13 5:44 
GeneralRe: c# Thumbnail Viewer Pin
Dave Kreskowiak18-May-13 7:46
mveDave Kreskowiak18-May-13 7:46 
GeneralRe: c# Thumbnail Viewer Pin
BillWoodruff19-May-13 2:05
professionalBillWoodruff19-May-13 2:05 
GeneralRe: c# Thumbnail Viewer Pin
Dinesh Salunke19-May-13 4:16
Dinesh Salunke19-May-13 4:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.