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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Multithreading in c#

Posted By:      Posted Date: August 27, 2010    Points: 0   Category :ASP.Net


Actually i want to upload a powerpoint file and do the conversion process(convert it to wmv) in the background so that i may not get blocked untill the process gets finished because it's a long process.How can i do that?Is ThreadPool can do that for me ?Any suggestions please ?

View Complete Post

More Related Resource Links

C# Multithreading

In this article let us see aboutmultithreading. Multithreaded applications provide the illusion thatnumerous activities are happening at more or less the same time. In C#the System.Threading namespace provides a number of types that enablemultithreaded programming.

Threading in C#

MultiThreading with C#

In order to understand completely what is a thread, how and when to useit we should first see how Windows operating system works."Windows is a preemptive multitasking operation system

Practical Multithreading for Client Apps

Writing applications that use multiple threads is often considered an advanced programming task, prone to errors. In this month's column, I'll focus on a practical application of multithreading in Windows® Forms applications with some real benefits, while attempting to keep things simple. My goal is to present multithreading in an approachable way that addresses a very common need: writing applications with a user interface that remain responsive to the user.

Multithreading in .NET Applications, Part 3

Multithreading is a powerful design tool for creating high-performance applications, especially those that require user interaction. Microsoft .NET has broken down the barriers that once existed in creating multithreaded applications. The last two installments of the .NET Nuts & Bolts column were

OpenMP and C++: Reap the Benefits of Multithreading without All the Work


Having more than one CPU core on a single chip makes a system with a processor with two cores operate just like a dual-processor computer, and a system with a processor with four cores operate like a quad-processor computer, so you get much better performance. But if your application does not take advantage of these multiple cores, you may not reap the benefits. OpenMP helps you create multithreaded C++ applications more quickly so the benefits of multithreading can be realized.

Kang Su Gatlin and Pete Isensee

MSDN Magazine October 2005

singleton class and multithreading


I have a singleton class thats used throughout an application.  The app will be multi threaded, each thread will access methods in the singleton class.  Is it best to create an instance of the singleton class at application startup then pass that into each thread, or is it safe to create an instance in each thread separately ?  (I check that no instance currently exists in the singleton class itself, so only 1 instance will ever be invoked)


Why do we have banking application implementing multi- threading? What are the scenarios banking applications provide that we use multi threading there? Thanks. 

Multithreading application

Hi all,i'm writing an asp.net c# web application that use different providers to authenticate the user. The function take all the providers with reflection, call them and store the result in a list. The problem is that if the provider use a lot of time to do some operations the page load is incredible slow. I need to cycle all the providers and call for each one a specific function, so i thought to use multithreading to execute the functions in parallels. Is it possible? How?

WinForms and Multithreading

Hello, I tried to write WinForm application. I want to simulate long CPU operations by(Sleep(4000)) in new thread and change a TextBox value, after 4 seconds in this thread too. When I use BeginInvoke function from new thread it works, but program stop responding for 4 seconds. BeginInvoke method should be executed asynchronous so, interface shouldn't be blocked for 4seconds.   Sorry for my bad english. If you can, please help me.   CODE:   using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Threading; namespace Watek1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { changeText(); } private void changeText() { if (this.InvokeRequired) { this.BeginInvoke(new MethodInvoker(changeText)); } else { Thread.Sleep(4000); textBox1.Text = "DONE"; } } } }  

Multithreading application to launch SSRS report muliple times

Hello, First of all, I am not a .net programmer but fortunately/unfortunately I have to create a scenario where I have to make multiple calls to SSRS report server. Is there a way to create a multithread web application whose threads will call the reports from the report server? I know how to execute a report from .net web application but I don't know how to do it when I have to launch many instances of the same report simultaneously. I believe that by creating multiple threads, I can make each thread to execute same report on report server. Moreover, I should be able to change the no. of threads (no. of threads should be the parameter) at the start of each execution. Since I am primarily a SQL developer and have no practical experience of implementing threading in .net, can anyone please help me out here? Regards.



Hellw guys, I have the following code


for(int i =0;i<100;i++)





this foo function exports pdf crystal reports, how can i start more than one thread to speedup this operation??

Multithreading and asp.net requests



I have a basic doubt on multithreading. I understand multithreading improves UI response and can be used for long operations. But when talking on asp.net requests and the thread pool, say that the main thread hand over its task to a new thread for the long awaiting operation. But it still uses another thread, so atleast one thread is serving the same request. But how does it improve other requests more fastly though the number of threads consumed are same here.

Multithreading Dynamic Shape Drawing on InkCanvas?


note: Multithreading code adapted from here http://elegantcode.com/2009/07/03/wpf-multithreading-using-the-backgroundworker-and-reporting-the-progress-to-the-ui/


The Problem:  The line is not rendered consistently, only on the mouseleftup event.

Scenario: 1. Michael clicks the Line button on the toolbar

2. Michael brings the mouse over the ink canvas and clicks the left mouse button

3. While moving the mouse to the right to draw a line, he notices that nothing shows up.

4. On releasing the mouses left button, the line finally renders correctly.

I realize that i most likely need to multithread to accomplish this.

To begin i have  a basic WPF setup, menu bars, borders, toolbars, and i have an ink canvas. The goal of this project is to familiarize myself with image editing and drawing programs. I created a basic Line2D class.


 public class Line2D
  BackgroundWorker worker;

  MainWindow window;
  InkCanvas canvas;
  Line lineToBuild;
  public Line2D(InkCanvas curren

Striping Backups to Achieve Multithreading


I know that if you stripe backups across multiple destinations, the backup process will assign a thread for each destination.  I would like to verify how multithreading works in regards to filegroup backups.  I've tried BOL, and google for a while, and haven't found a clear answer.  My question is really two-parts:

  1. If I back up multiple file groups, all to the same destination, does each filegroup backup get a thread of its own?  For example: say i have filegroup x and y. If I back up both filegroups to drive 1, will two threads be used?
  2. Could those filegroup backups be striped across multiple destinations to achieve even further multithreading? For example: say I have filegoup x and y.  If I stripe filegroup x's backup across drive 1 and 2, and I stripe filegroup y's backup across drive 3 and 4, will four threads be used?

Our full backups are reaching 9+ hours.  The vast majority of the data in the database is varbinary(max) data.  We are running SQl Server 2008 SP1 on Windows Server 2008 R2.

Any input, or links to good information about this subject will be greatly appreciated.  Thanks!


Multithreading with blinking label


Hello every1!

I've found some interesting links on the web about backgroundworker for .net CF, I'm trying to do a loop while a blink label shows "Working...". First when I declare: using backgroundworker I get the error:

Error 1 The type 'System.ComponentModel.BackgroundWorker' exists in both 'C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.dll' and 'C:\Documents and Settings\ACabrera\Desktop\AsynchCalcPi\BackgroundWorker\BackgroundWorker.dll' C:\Documents and Settings\ACabrera\my documents\visual studio 2010\Projects\WindowsFormsApplication3\WindowsFormsApplication3\Form1.cs 9 7 WindowsFormsApplication3

the links:


Have anyone tested this before?

Multithreading question


Hello there,

I want to show a message while a consuming time operation runs. I know that I've to use a thread for that. But why I can't use it in this way:

private void button1_Click(object sender, EventArgs e)
    ThreadPool.QueueUserWorkItem(new WaitCallback(ShowWorking));
//Consuming time operation
  for (int i=0;i<10000;i++)

private void ShowWorking(object stateinfo)
  this.Invoke(new EventHandler(updMsg))

private void updMsg(object sender, EventArgs e)
  lblWorking.Visible = true;

Why I have to put in the thread the consuming time operation?

Thx in >>

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

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