Explain how to use the Begin and End methods on a Web Service to make an asynchronous method call.

1 Answer

Answer :

Every public Web method on a Web Service can be called either synchronously or asynchronously. To make an asynchronous call to a Web method, you call the method named Begin, where is the name of the method. This method requires a delegate to an appropriate callback method and returns a value of IAsyncResult. This value is returned as a parameter in the callback method. To retrieve the data returned by the Web method, call End, supplying a reference to the IAsyncResult returned by Begin. This will allow you to retrieve the actual data returned by the Web method.

Related questions

Description : Are events synchronous of asynchronous? 

Last Answer : Asynchronous

Description : Methods must declare a return type, what is the keyword used when nothing is returned from the method?

Last Answer : void 

Description : Which method will you call to start a thread?

Last Answer : Start

Description : What si the difference between interface and abstractclass Select Answer:  1. interface contain only methods  2. we can't declare a variable for interface  3. interface contain only events  4. None  5. All

Last Answer : Ans : 2 The only Difference between Interface and Abstract class is we can declare a variable in abstract class but we can't declare in variable interface

Description : Describe Break mode and some of the available methods for navigating in Break mode.

Last Answer : Break mode allows you to observe program execution on a line-by-line basis. You can navigate program execution in Break mode by using Step Into, Step Over, Step Out, Run To Cursor, and Set Next Statement.

Description : Why can’t you specify the accessibility modifier for methods inside the interface?

Last Answer : They all must be public, and are therefore public by default. 

Description : Can abstract methods override virtual methods? 

Last Answer : Yes

Description : Can a struct have methods?

Last Answer : Yes

Description : Write some code using interfaces, virtual methods, and an abstract class.

Last Answer : using System; public interface Iexample1 { int MyMethod1(); } public interface Iexample2 { int MyMethod2(); } public abstract class ABSExample : Iexample1, Iexample2 { public ABSExample( ... override void VIRTMethod2() { System.Console.WriteLine("VIRTMethod2 has been overridden"); } }

Description : Class methods to should be marked with what keyword?

Last Answer : static

Description : Why can’t you specify the accessibility modifier for methods inside the interface?

Last Answer : They all must be public, and are therefore public by default.

Description : Why can’t you specify the accessibility modifier for methods inside the interface? 

Last Answer : They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.

Description : Can you override private virtual methods? 

Last Answer : No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access. 

Description : Can you override private virtual methods?

Last Answer : No. Private methods are not accessible outside the class.

Description : Can you override private virtual methods?

Last Answer : No, private methods are not accessible outside the class.

Description : Define what is the difference between static and instance methods?

Last Answer : A method declared with a static modifier is a static method. A static method does not operate on a specific instance and can only access static members. A method declared without a static modifier is an ... can be explicitly accessed as this. It is an error to refer to this in a static method.

Description : Define what is methods?

Last Answer : A method is a member that implements a computation or action that can be performed by an object or class. Static methods are accessed through the class. Instance methods are accessed through instances of the class.

Description : Define what is the difference between “throw ex” and “throw” methods in C#?

Last Answer : “throw ex” will replace the stack trace of the exception with stack trace info of rethrowing point. “throw” will preserve the original stack trace info.

Description : Define what is the difference between “finalize” and “finally” methods in C#?

Last Answer : Finalize – This method is used for garbage collection. So before destroying an object, this method is called as part of the cleanup activity. Finally – This method is used for executing the code irrespective of exception occurred or not.

Description : When should you call the garbage collector in .NET?

Last Answer : As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice. 

Description : If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?

Last Answer : Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

Description : When should you call the garbage collector in .NET?

Last Answer : As a good rule, you should not call the garbage collector. However, you could call the garbage collector when you are done using a large object (or set of objects) to force the garbage collector to dispose of those very large objects from memory. However, this is usually not a good practice.

Description : If a base class has a number of overloaded constructors, and an inheriting class has a number of overloaded constructors; can you enforce a call from an inherited constructor to a specific base constructor?

Last Answer : Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.

Description : If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor? 

Last Answer : Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class. 

Description : How do you debug an ASP.NET Web application?

Last Answer : Attach the aspnet_wp.exe process to the DbgClr debugger. 

Description : How do you debug an ASP.NET Web application?

Last Answer : Attach the aspnet_wp.exe process to the DbgClr debugger.

Description : Can we use “this” inside a static method in C#?

Last Answer : No. We can’t use “this” in a static method.

Description : What is method overloading, and when is it useful?

Last Answer : Method overloading allows you to create several methods with the same name but different signatures. Overloading is useful when you want to provide the same or similar functionality to different sets of parameters.

Description : What does the Dispose method do with the connection object? 

Last Answer : Deletes it from the memory. To Do: answer better. The current answer is not entirely correct.

Description : What does assert() method do?

Last Answer : In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true. 

Description : What are the different ways a method can be overloaded?

Last Answer : Different parameter data types, different number of parameters, different order of parameters.

Description : Can you declare an override method to be static if the original method is not static? 

Last Answer : No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)

Description : How is method overriding different from method overloading? 

Last Answer : When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.

Description : What does the keyword “virtual” declare for a method or property? 

Last Answer : The method or property can be overridden. 

Description : What’s the implicit name of the parameter that gets passed into the set method/property of a class?

Last Answer : Value. The data type of the value parameter is defined by whatever data type the property is declared as.

Description : What happens if you inherit multiple interfaces and they have conflicting method names?

Last Answer : It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay. To Do: Investigate 

Description : Can you allow a class to be inherited, but prevent the method from being over-ridden?

Last Answer : Yes. Just leave the class public and make the method sealed. 

Description : Are value types are slower to pass as method parameters? 

Last Answer : Yes

Description : What is an overloaded method?

Last Answer : An overloaded method has multiple signatures that are different. 

Description : Write code to show how a method can accept a varying number of parameters.

Last Answer : using System; namespace Console1 { class Class1 { static void Main(string[] args) { ParamsMethod(1,"example"); ParamsMethod(1,2,3,4); Console.ReadLine(); } static void ... o in list) { Console.WriteLine(o.ToString()); } } } }

Description : What does the Dispose method do with the connection object? 

Last Answer : Deletes it from the memory. To Do: answer better. The current answer is not entirely correct.

Description : What does assert() method do? 

Last Answer : In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true. 

Description : What are the different ways a method can be overloaded?

Last Answer : Different parameter data types, different number of parameters, different order of parameters.

Description : Can you declare an override method to be static if the original method is not static? 

Last Answer : No. The signature of the virtual method must remain the same. (Note: Only the keyword virtual is changed to keyword override)

Description : How is method overriding different from method overloading? 

Last Answer : When overriding a method, you change the behavior of the method for the derived class. Overloading a method simply involves having another method with the same name within the class.

Description : What does the keyword “virtual” declare for a method or property? 

Last Answer : The method or property can be overridden.

Description : What’s the implicit name of the parameter that gets passed into the set method/property of a class?

Last Answer : Value. The data type of the value parameter is defined by whatever data type the property is declared as.

Description : What happens if you inherit multiple interfaces and they have conflicting method names?

Last Answer : It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.  To Do: Investigate 

Description : Can you allow a class to be inherited, but prevent the method from being over-ridden?

Last Answer : Yes. Just leave the class public and make the method sealed. 

Description : How can you overload a method?

Last Answer : Different parameter data types, different number of parameters, different order of parameters.