void OnPingButtonClicked()
 {
     SimplePingHelper.Ping(
         _hostNameElement.Value,
         1000,
         () => {
         NSThread.MainThread.BeginInvokeOnMainThread(new NSAction(() => {
             var alertView = new UIAlertView("Response", "Success", null, null, new string[] { "Ok" });
             alertView.Show();
         }));
     },
         () => {
         NSThread.MainThread.BeginInvokeOnMainThread(new NSAction(() => {
             var alertView = new UIAlertView("Response", "Failure", null, null, new string[] { "Ok" });
             alertView.Show();
         }));
     });
 }
		public static void Ping(string hostName, int timeout, Action success, Action failure)
		{
			var helper = new SimplePingHelper (hostName, timeout);
			helper.Succedded += (object sender, EventArgs e) => {
				if(success != null)
					success();
				(sender as SimplePingHelper).Release();
				(sender as SimplePingHelper).Dispose();
			};
			helper.Failed += (object sender, EventArgs e) => {
				if(failure != null)
					failure();
				(sender as SimplePingHelper).Release();
				(sender as SimplePingHelper).Dispose();
			};
			helper.Retain ();
			helper.Go ();
		}
Ejemplo n.º 3
0
        public static void Ping(string hostName, int timeout, Action success, Action failure)
        {
            var helper = new SimplePingHelper(hostName, timeout);

            helper.Succedded += (object sender, EventArgs e) => {
                if (success != null)
                {
                    success();
                }
                (sender as SimplePingHelper).Release();
                (sender as SimplePingHelper).Dispose();
            };
            helper.Failed += (object sender, EventArgs e) => {
                if (failure != null)
                {
                    failure();
                }
                (sender as SimplePingHelper).Release();
                (sender as SimplePingHelper).Dispose();
            };
            helper.Retain();
            helper.Go();
        }