In the event of a button of my APP had the following code it worked running in the android emulator, but when I passed the app to the cell phone generates a message the app stopped.
Button buttonPessoasNecessita = FindViewById<Button> (Resource.Id.mybuttonPesNec);
buttonPessoasNecessita.Click += delegate {
Service1Client client;
var binding = new BasicHttpBinding () { Name= "basicHttpBinding", MaxReceivedMessageSize = 67108864,};
binding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
{ MaxArrayLength = 2147483646, MaxStringContentLength = 5242880, };
var timeout = new TimeSpan(0,60,60);
binding.SendTimeout= timeout;
binding.OpenTimeout = timeout;
binding.ReceiveTimeout = timeout;
client = new Service1Client(binding, new EndpointAddress ("http://engb.uni5.net/Service1.svc"));
buttonPessoasNecessita.text = client.envioPessoa();
};
Trying to solve the case I thought of using asynchronous, I looked for several examples but none was clear to me and I saw that my client object exists a method has a beginenvio methodPessoa () and another endenvioPessoa (); Based on this link Easy way to use WCF service with async / await tried to set up a method to consume the web service in an async way
method call:
var t = await executeAsync(binding);
Method:
public async Task<string> executeAsync(BasicHttpBinding binding){
Service1Client client = new Service1Client(binding, new EndpointAddress ("http://engb.uni5.net/Service1.svc"));
var t = Task<string>.Factory.FromAsync (
((IService1)client.InnerChannel).BeginenvioPessoa,
((IService1)client.InnerChannel).EndenvioPessoa);
return await t;
}
In the end my code does not work it displays syntax errors
Error CS1502: The best overloaded method match for 'System.Threading.Tasks.TaskFactory.FromAsync (System.IAsyncResult, System.Func) 'has some invalid arguments (CS1502)
Error CS1503: Argument 1: can not convert from 'method group' to 'System.IAsyncResult' (CS1503)