//THis works like a charm :) private void StartTimeout(bool stop) { //This action is: 'Hide the notification, and set the timeoutStarted as finished(false) //because this action will be invoked only when the timeout has finished. //If the timeout has started, then cancel the action, and start again. if (stop) { maincontainer?.RemoveCallbacks(HideNotification); //Stop counting. return; } else { if (timeoutStarted == true) { maincontainer?.RemoveCallbacks(HideNotification); maincontainer?.PostDelayed(HideNotification, 7000); } //If not, simply wait 5 seconds then hide the notification, in that span of time, the timeout is //marked as Started(true) else { timeoutStarted = true; maincontainer?.PostDelayed(HideNotification, 7000); } } }
public void onIpEndPointReceived(IPEndPoint endPoint) { mViewIp.PostDelayed(() => { mViewIp.Visibility = ViewStates.Visible; mTxtViewIpAddress.Text = string.Format("Ip Address : {0}", endPoint.Address); mTxtViewLogs.Text += string.Format("Ip Address : {0}\n", endPoint.Address); }, 100); }
//THis works like a charm :) private void StartTimeout() { //This action is: 'Hide the notification, and set the timeoutStarted as finished(false) //because this action will be invoked only when the timeout has finished. Action hideNotification = () => { notification.Visibility = ViewStates.Gone; timeoutStarted = false; }; //If the timeout has started, then cancel the action, and start again. if (timeoutStarted == true) { notification?.RemoveCallbacks(hideNotification); notification?.PostDelayed(hideNotification, 5000); } //If not, simply wait 5 seconds then hide the notification, in that span of time, the timeout is //marked as Started(true) else { timeoutStarted = true; notification?.PostDelayed(hideNotification, 5000); } }
private void StartTimeout(bool start) { if (start == false) { maincontainer?.RemoveCallbacks(HideMusicWidget); //Stop counting. return; } else { if (timeoutStarted == true) { maincontainer?.RemoveCallbacks(HideMusicWidget); maincontainer?.PostDelayed(HideMusicWidget, 7000); } //If not, simply wait 7 seconds then hide the notification, in that span of time, the timeout is //marked as Started(true) else { timeoutStarted = true; maincontainer?.PostDelayed(HideMusicWidget, 7000); } } }