DOT NET
#1

Presented by:
M.MOURYA

[attachment=11066]
Explain the concept of Asynchronous Programming in detail.
The .NET Framework allows you to call any method asynchronously. Define a delegate with the same signature as the method you want to call; the common language runtime automatically defines BeginInvoke and EndInvoke methods for this delegate, with the appropriate signatures.
The BeginInvoke method is used to initiate the asynchronous call. It has the same parameters as the method you want to execute asynchronously, plus two additional parameters that will be described later. BeginInvoke returns immediately and does not wait for the asynchronous call to complete. BeginInvoke returns an IasyncResult, which can be used to monitor the progress of the call.
The EndInvoke method is used to retrieve the results of the asynchronous call. It can be called any time after BeginInvoke; if the asynchronous call has not completed, EndInvoke will block until it completes. The parameters of EndInvoke include the out and ref parameters (<Out>ByRef and ByRef in Visual Basic) of the method you want to execute asynchronously, plus the IAsyncResult returned by BeginInvoke.
Note The IntelliSense feature in Visual Studio .NET displays the parameters of BeginInvoke and EndInvoke. If you are not using Visual Studio or a similar tool, or if you are using C# with Visual Studio .NET, see Asynchronous Method Signatures for a description of the parameters the runtime defines for these methods.
The code in this topic demonstrates four common ways to use BeginInvoke and EndInvoke to make asynchronous calls. After calling BeginInvoke you can:
Do some work and then call EndInvoke to block until the call completes.
Obtain a WaitHandle using IAsyncResult.AsyncWaitHandle, use its WaitOne method to block execution until the WaitHandle is signaled, and then call EndInvoke.
Poll the IAsyncResult returned by BeginInvoke to determine when the asynchronous call has completed, and then call EndInvoke.
Pass a delegate for a callback method to BeginInvoke. The method is executed on a ThreadPool thread when the asynchronous call completes, and can call EndInvoke.
All four samples use the same long-running test method, TestMethod. This method displays a console message to show that it has begun processing, sleeps for a few seconds, and then ends. TestMethod has an out parameter (<Out> ByRef in Visual Basic) to demonstrate the way such parameters are added to the signatures of BeginInvoke and EndInvoke. You can handle ref parameters (ByRef in Visual Basic) similarly.
The following code example shows TestMethod and the delegate that represents it; to use any of the samples, append the sample code to this code.
2. Define Thread and explain the concept of Multithreading.
One of the greatest understatements I've heard in a newsgroup was made by Patricia Shanahan, in a Java newsgroup in 2001: "Multi-threaded programming needs a little care." Multi-threading is probably one of the worst understood aspects of programming, and these days almost all application programmers need to understand it to some extent. This article acts as an introduction to multi-threading and gives some hints and tips for how to do it safely. Warning: I'm not an expert on the subject, and when the real experts start discussing it in detail, my head starts to spin somewhat. However, I've tried to pay attention to those who know what they're doing, and hopefully the contents of this article form at least part of a multi-threading "best practice".
This article uses the C# type shorthands throughout - int for Int32 etc. I hope this makes it easier for C# developers to read, and won't impede any other developers too much. It also only talks about the C# ways of declaring variables to be volatile and locking monitors. Developers using other languages can find the equivalents in their own preferred environment, I'm sure.
Introduction: What is multi-threading?
The fact that you're reading this article in the first place means you probably have at least some idea of what multi-threading is about: it's basically trying to do more than one thing at a time within a process.
So, what is a thread? A thread (or "thread of execution") is a sort of context in which code is running. Any one thread follows program flow for wherever it is in the code, in the obvious way. Before multi-threading, effectively there was always one thread running for each process in an operating system (and in many systems, there was only one process running anyway). If you think of processes running in parallel in an operating system (e.g. a browser downloading a file and a word processor allowing you to type, both "at the same time"), then apply the same kind of thinking within a single process, that's a reasonable way to visualise threading.
Multi-threading can occur in a "real" sense, in that a multi-processor box may have more than one processor executing instructions for a particular process at a time, or it may be effectively "simulated" by multiple threads executing in sequence: first some code for thread 1 is executed, then some code for thread 2, then back to thread 1 etc. In this situation, if both thread 1 and thread 2 are "compute bound" (all they're doing is computation, without waiting for any input from the network, or file system, or user etc) then that won't actually speed things up at all - in fact, it'll slow things down as the operating system has to switch between threads, and the memory cache probably won't be as effective. However, much of today's computing involves waiting for something to happen, and during that time the processor can be doing something else. Intel's "Hyper-Threading" technology which is on some of its more recent chips (bearing in mind that this article was written in early 2004!) is a sort of hybrid between this "real" and "simulated" threading - for more information, see Intel's web page on the subject.
How does multi-threading work in .NET?
.NET has been designed from the start to support multi-threaded operation. There are two main ways of multi-threading which .NET encourages: starting your own threads with ThreadStart delegates, and using the ThreadPool class either directly (using ThreadPool.QueueUserWorkItem) or indirectly using asynchronous methods (such as Stream.BeginRead, or calling BeginInvoke on any delegate).
In general, you should create a new thread "manually" for long-running tasks, and use the thread pool only for brief jobs. The thread pool can only run so many jobs at once, and some framework classes use it internally, so you don't want to block it with a lot of tasks which need to block for other things. The examples in this article mostly use manual thread creation. On the other hand, for short-running tasks, particularly those created often, the thread pool is an excellent choice.
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: calendering, multithreading delegate, who is patricia baeza, clr dll strongnametype,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Messages In This Thread
DOT NET - by seminar class - 26-03-2011, 02:08 PM
RE: DOT NET - by seminar class - 22-04-2011, 10:09 AM
RE: DOT NET - by seminar class - 22-04-2011, 10:36 AM
RE: DOT NET - by seminar class - 11-05-2011, 04:18 PM
RE: DOT NET - by seminar details - 03-10-2012, 03:47 PM

Possibly Related Threads...
Thread Author Replies Views Last Post
  Net- Banking mechanical engineering crazy 4 5,624 02-12-2012, 03:33 PM
Last Post: Guest
  application projects in java and vb.net (titles and topics) project topics 1 5,505 28-11-2012, 01:11 PM
Last Post: seminar details
  Net Auction java based project report project topics 2 3,714 01-11-2012, 12:59 PM
Last Post: seminar details
  Net Auction mechanical engineering crazy 1 2,340 01-11-2012, 12:59 PM
Last Post: seminar details
  dot net projects list ideas and topics project topics 1 4,793 14-03-2012, 12:29 PM
Last Post: seminar paper
  dot net project titles electronics seminars 6 12,854 14-03-2012, 12:29 PM
Last Post: seminar paper
  dot net projects project topics 1 2,939 14-03-2012, 12:29 PM
Last Post: seminar paper
  dot net projects list free download project topics 1 9,073 14-03-2012, 12:29 PM
Last Post: seminar paper
  Webgrabber (Using Java or .NET) project topics 5 3,852 27-02-2012, 10:51 AM
Last Post: seminar paper
  e-learning project in java and asp.net ideas project topics 1 2,989 23-02-2012, 03:54 PM
Last Post: seminar paper

Forum Jump: