.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

Problem canceling asynchronous method

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :.NET Framework


I want to canceling an asynchronous method.

How can me it?


public IAsyncResult BeginGetAllUsersCount(object sender, EventArgs args, AsyncCallback callback, object state)
       //Canceling asynchronous operation
     return AdapterUser.BeginGetAllUsersCount(callback);

   public void EndGetAllUsersCount(IAsyncResult asyncResult)
     _totalRowsCount = AdapterUser.EndGetAllUsersCount(asyncResult);




View Complete Post

More Related Resource Links

Concurrent Affairs: Solving The Dining Philosophers Problem With Asynchronous Agents


We use the new Asynchronous Agents Library in Visual C++ 2010 to solve the classic Dining Philosophers concurrency problem.

Rick Molloy

MSDN Magazine June 2009

.NET Delegates: Making Asynchronous Method Calls in the .NET Environment


One of the many great features of the .NET Framework is that it has asynchronous infrastructure built in. In .NET you can call any method asynchronously by defining a delegate for the method and calling the delegate's asynchronous methods. This is beneficial to your application because when a synchronous call is made, the calling thread is blocked until the method completes whereas an asynchronous call is made on a different thread, and this allows the original thread to continue its work while the asynchronous call is in progress.This article explains delegates in .NET and how to use them to perform asynchronous calls, eliminating age-old threading problems.

Richard Grimes

MSDN Magazine August 2001

Windows 2000: Asynchronous Method Calls Eliminate the Wait for COM Clients and Servers


Windows 2000 is the first version of COM to support asynchronous method calls, which permit clients to make nonblocking calls to COM objects and objects to process incoming calls without blocking the calling threads. COM clients benefit from asynchronous method calls because they can continue working while waiting for outbound calls to return. Objects benefit because they can queue incoming calls and service them from a thread pool. Our SieveClient and SieveServer sample apps demonstrate how to create and use asynchronous clients and servers in COM-based distributed applications.

Jeff Prosise

MSDN Magazine April 2000

Problem with Finder method with parameters



Could someone explain me how to provide some value to the parameters in a finder method. For exemple I know that the BDC list WP use this method. Is there a way to provide some value for those parameter at runtime? I really don't understand (even after some deep search on the web) where are the values for the parameters from and how we can connect to them. Even with C# code I can't find any information on how it work.

I don't want to define my parameters as filter in the ADF because then I will have this filter section in my BDC list WP (or is there a way to get rid of that?). Actually one of the parameter should be automatically calculated from a value in a SP list, the other parameter should be provided by my own filter web part.

Thank you for your help.

C# Asynchronous Sockets Problem

Dear Programmers, I have some trouble in using Asynchronous Sockets in my application . My C# Window Application Working as Server and several clients to this Server and start data transmitting. Sometimes from a particular  Client i got continues Null Value Client exactly not sending but i m receiving and my application got hang and stop working , What is the problem can any one help me to resolve this problem .   Thanks  JainAmit      

Problem with overriding OnPaint method of System.Windows.Forms.Textbox

Hi,   I want to change the border colour of the Textbox. However, when I override the OnPaint method, some strange behaviour occurs.   The new border is drawn, as is the textbox background. However, the text itself appears in bold and only while I actually type something in, afterwards it disappears. I have provided a sample of my code here:         protected override void OnPaint(PaintEventArgs e)         {             base.OnPaint(e);             Rectangle rect = new Rectangle(0, 0, this.Width, this.Height);             ControlPaint.DrawBorder(e.Graphics, rect, _BorderColour, ButtonBorderStyle.Solid);         }   I have also set the style of the control to Userpaint, so that the paint method is actually used. Does anybody know how to solve this issue?

Problem using value() method for xml datatypes.

Hi i'm working on an application which stored infopath forms in database as xml datatype. now i want to get query of xml data which returns each node as sql dataType (column). here is my sample form data : <?mso-infoPathSolution solutionVersion="" productVersion="12.0.0" PIVersion="" href="file:///D:\customForm3.xsn" name="urn:schemas-microsoft-com:office:infopath:customForm3:-myXSD-2010-09-11T10-56-47" ?> <?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?> <my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2010-09-11T10:56:47" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us"> <my:txtFirstName>test1</my:txtFirstName> <my:txtLastName>test2</my:txtLastName> <my:txtFatherName>test3</my:txtFatherName> <my:txtNationalCode>8278273828</my:txtNationalCode> <my:cmbReuqesType>2</my:cmbReuqesType> <my:dtmRequestDate>2010-09-17</my:dtmRequestDate> <my:txtDescription>test4</my:txtDescription> </my:myFields> to get query of this

Problem while calling WCF method


I have a WCF Service and a client application. WCF Service has an operation contract (say UpdateTables()) with IsOneWay = True. I call this method of WCF Service from my client application using the code below:
   Private Sub UpdateTable_Client()
        Dim WCFSvcObject As New MyFirstWCFServiceClient
        Dim WCFSvcData as new MyFirstWCFDataRequest 'DataContract object
        WCFSvcData.TableName = "Customer"
        WCFSvcData.ColumnName = "Name"
        Catch ex As Exception
            Throw ex
            If WCFSvcObject  IsNot Nothing Then               
            End If
        End Try
    End Sub

Sometimes this call reaches to WCF Service successfully but sometime it lost and UpdateTable() method could not be invoked on service side. I am not sure but I think WCFSvcObject.Abort() code aborts the WCF request before it reaches to the service. I can not use Close() method here as my client application hangs on the Close().
Please suggest me what may be the reasons of the client call could not reach to the WCF Service. Should I not use Abort() method. If yes then how can I dispose the WCF proxy(since Close() method is not working here).

Problem creating method?


I added the extender and when i tried to add the method this message poped up;

Cannot create page method "GetCompletionList" because no Code Behind or codefile was found.

does anyone know why this is happening?

Thanks  =)

Unusual problem using a class method


I have a class that runs calculations on numbers and populates the results to my SQL database.  My code behind page instantiates the class object, and in a loop it makes use of the method five times (once per loop).  Essentially, my code behind collects the information from controls and passes the information to the class method for processing.  The method works just fine most of the time.

On one of the iterations I get a error before the code even gets to the class.  The error is, "Arithmetic operation resulted in an overflow."  What strikes me as odd is that while stepping through the code, the loop crashes with that error before getting to the class that runs the calculations.  Additionally, no arethmetic operations are performed on the form's code-behind page (which calls the method).  I even put a break-point on the class constructor but the code crashed before reaching that constructor.

The information being sent is the results of matches from a sporting event.  As a troubleshooting measure I changed the order of the matches by deleting them an re-entering them into the database in a different order.  Again only this one particular match crashed.

Here is the code that crashes:

cRating.SetRating(dMatchDate, iSetID, 8, iHPlayerID, 

problem with my method


this method is meant to retrieve two database field values, but i'm getting error: Must declare the scalar variable "@FlyingFrom".

 public static string GetDepartureFlightId()

            //sql query
            string sqlQuery = @"SELECT DepartureId
                                FROM Flights WHERE FlyingFrom = @FlyingFrom"; 

            using (SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString))
                string depId = "";
                string flyingFrom = "";
                SqlCommand myCommand = new SqlCommand(sqlQuery, myConnection);

                SqlDataReader reader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

                while (reader.Read())
                    depId = reader["DeparturedId"].ToString();
                    flyingFrom = reader["FlyingFrom"].ToString();


                return sqlQuery;


Problem in inserting another entity via overriding insert method


I have problem to inserting another entity in overriding method of first entity my code sample is like bellow :

partial void InsertEntity1 ( Entity1 instance )


     Entity2 x = new Entity2() ;

tihs.Entity2s.Add(x) ;





in inserting Entity2 I get Exception "The Operation Cannot be perform for the entity because it is not being change track"


problem on indexOf() method



Whats wrong in this code? I can not use indexOf method.

        function CancelPostback() {
            var TextBoxDescription
            TextBoxDescription = document.getElementById('<%=(((Master.FindControl("MainContent")).FindControl("FormViewPO")).FindControl("DescriptionTextBox")).ClientID %>');
            alert(TextBoxDescription.value)  // working. Alert shows value of the textbox
            //  alert(TextBoxDescription.value.indexOf("a")) // not working. even no alert
            //  alert(TextBoxDescription.indexOf("a")) // not working. even no alert
            //  alert(TextBoxDescription.value.indexOf('a')) // not working. even no alert
            //  alert(TextBoxDescription.indexOf('a')) // not working. even no alert

DataBinding + Extension Method Problem


Inside my repeater I'm calling an extension method like so:


<asp:label id="fileSize" runat="server" text='<%# ((UploadedFile)DataBinder.GetDataItem(Container.DataItem)).Size() %>' />


he above is giving me an "Object not set to an instance of a object" exception inside the extension method. If I comment the above expression out, it works fine, and the items are binded wtih no problems. Any ideas?

Problem with the XMLNodeList.SelectSingleNode method



I was doing an experiment with the XML. Bellow given is XML file


I have written the following piece of code to get the NodeList

private ConfigData ReadConfig()
            XmlDocument powerDoc = new XmlDocument();
            ConfigData config = null;
            XmlNode node = null;
            XmlNodeList emailList = null;

Executing a callback method when the asynchronous operation returns


Hi, I really don't understand the physical meaning of "callback" in the real world although a lot of code there. Can somebody give me a real world example to explain it?(not code itself)?

Thank you very much.

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