Good morning everyone. I'm having a problem with this code that I'm trying to understand. I get a red wiggly line under the word "proxy.BeginAdd(" , this looks really wierd in that the closing parentheses is missing. It looks like a typo but since this is lambda and i don't know squat about lambda maybe this is legal? Can any of you guys guess at how this is supposed to be written if it is a typo? Or can you tell me what was the meant writing? Just placing a closing parenthesese around => didn't fix it. Also I don't know what "ar" is or where it's coming from either. Can someone please take a look at this and give me a hand?
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MathClient.ServiceReference1;
using System.Threading;
namespace MathClient
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***** The Async Math Client *****\n");
using (BasicMathClient proxy = new BasicMathClient())
{
proxy.Open();
//add numbers in an async manner, using a lambda expression.
IAsyncResult result = proxy.BeginAdd(2, 3, //red squiggly line under proxy.BeginAdd(
ar =>
{
Console.WriteLine("2 + 5 = {0}, proxy.EndAdd(ar));
}
while (!result.IsCompleted)
{
Thread.Sleep(200);
Console.WriteLine("Client working...");
}
Console.ReadLine();
}
}
}
}
Hi there. Thanks a lot. It goes like this now and everything works.
Code:
static void Main(string[] args)
{
Console.WriteLine("***** The Async Math Client *****\n");
using (BasicMathClient proxy = new BasicMathClient())
{
proxy.Open();
//add numbers in an async manner, using a lambda expression.
IAsyncResult result = proxy.BeginAdd(2, 3,
ar =>
{
Console.WriteLine("2 + 5 = {0}", proxy.EndAdd(ar));
},null);
while (!result.IsCompleted)
{
Thread.Sleep(200);
Console.WriteLine("Client working...");
}
Console.ReadLine();
}
}
Bookmarks