public void TimerStart() { TimerStop(); TimerReset(); if (OnStart != null) { OnStart.Invoke(currentTime); } subscribe = Observable.Interval(System.TimeSpan.FromSeconds(1)).Select(_ => currentTime).Where(_ => _ > 0).Subscribe(_ => { currentTime--; if (OnUpdate != null) { OnUpdate.Invoke(currentTime); } if (currentTime == 0) { subscribe.Dispose(); if (OnOver != null) { OnOver.Invoke(); } } }); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private static void closeIfNotNull(java.io.Closeable closeable) throws java.io.IOException private static void CloseIfNotNull(System.IDisposable closeable) { if (closeable != null) { closeable.Dispose(); } }
public static void ForeachCompilerCodeDemo() { var people = new List <Person> { new Person() { FirstName = "John", LastName = "Doe" }, new Person() { FirstName = "Jane", LastName = "Doe" }, }; List <Person> .Enumerator e = people.GetEnumerator(); try { Person v; while (e.MoveNext()) { v = e.Current; } } finally { System.IDisposable d = e as System.IDisposable; if (d != null) { d.Dispose(); } } }
private bool validata(string theme) { DropdownColumn dropdownColumn = (DropdownColumn)this.grdTopCategries.Columns[1]; System.Collections.IEnumerator enumerator = this.grdTopCategries.Rows.GetEnumerator(); bool result; try { while (enumerator.MoveNext()) { System.Web.UI.WebControls.GridViewRow gridViewRow = (System.Web.UI.WebControls.GridViewRow)enumerator.Current; string a = dropdownColumn.SelectedValues[gridViewRow.RowIndex]; if (a == theme) { result = false; return(result); } } return(true); } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(result); }
// Foreach is readonly since foreach is syntactic sugar for the following logic. // If change reference, then enumerator won't be able to find the next object in the collection - // hence the object reference is readonly. public static void TestEnumeratorForEach() { var people = new List <Person> { new Person() { FirstName = "John", LastName = "Doe" }, new Person() { FirstName = "Jane", LastName = "Doe" }, }; List <Person> .Enumerator e = people.GetEnumerator(); try { Person v; while (e.MoveNext()) { v = e.Current; // If change value for v, then enumerator will not be able to locate next object in the collection. } } finally { System.IDisposable d = e as System.IDisposable; if (d != null) { d.Dispose(); } } }
protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e) { if (this.trackItemsPropChanges) { switch (e.Action) { case NotifyCollectionChangedAction.Add: { System.Collections.IEnumerator enumerator = e.NewItems.GetEnumerator(); try { while (enumerator.MoveNext()) { T item = (T)((object)enumerator.Current); item.PropertyChanged += new PropertyChangedEventHandler(this.item_PropertyChanged); } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } break; } case NotifyCollectionChangedAction.Remove: { System.Collections.IEnumerator enumerator = e.OldItems.GetEnumerator(); try { while (enumerator.MoveNext()) { T item = (T)((object)enumerator.Current); item.PropertyChanged -= new PropertyChangedEventHandler(this.item_PropertyChanged); } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } break; } case NotifyCollectionChangedAction.Reset: foreach (T item in base.Items) { item.PropertyChanged += new PropertyChangedEventHandler(this.item_PropertyChanged); } break; } } base.OnCollectionChanged(e); }
public void Dispose() { truthSub?.Dispose(); tickSub?.Dispose(); truthSub = null; tickSub = null; }
static void Main(string[] args) { var people = new List <Person> { new Person() { FirstName = "Willamar", LastName = "Fernandes" }, new Person() { FirstName = "Willian", LastName = "Fernandes" } }; List <Person> .Enumerator e = people.GetEnumerator(); try { Person v; while (e.MoveNext()) { v = e.Current; Console.WriteLine(v.FirstName); } } finally { System.IDisposable d = e as System.IDisposable; if (d != null) { d.Dispose(); } } Console.Read(); }
private void SingletonDomainUnload(object source, System.EventArgs arguments) { bool mustReleaseLock = false; System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions(); try { System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions(); System.Threading.Monitor.Enter(ModuleUninitializer.@lock, ref mustReleaseLock); System.Collections.IEnumerator enumerator = this.GetEnumerator(); try { while (enumerator.MoveNext()) { ((System.EventHandler)enumerator.Current)(source, arguments); } } finally { System.IDisposable source2 = enumerator as System.IDisposable; if (source2 != null) { source2.Dispose(); } } } finally { if (mustReleaseLock) { System.Threading.Monitor.Exit(ModuleUninitializer.@lock); } } }
protected void btnDel_Click(object sender, System.EventArgs e) { System.Collections.IEnumerator enumerator = this.gvResource.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { GridViewRow gridViewRow = (GridViewRow)enumerator.Current; CheckBox cb = gridViewRow.FindControl("cbBox") as CheckBox; if (cb != null && cb.Checked) { using (pm2Entities pm2Entities = new pm2Entities()) { if (base.Request["num"] == "1") { Res_Template res_Template = ( from m in pm2Entities.Res_Template where m.TemplateId == cb.ToolTip select m).FirstOrDefault <Res_Template>(); if (res_Template != null) { res_Template.IsValid = new bool?(false); pm2Entities.SaveChanges(); } } else { IQueryable <Res_TemplateItem> queryable = from m in pm2Entities.Res_TemplateItem where m.Res_Template.TemplateId == cb.ToolTip select m; foreach (Res_TemplateItem current in queryable) { pm2Entities.DeleteObject(current); } Res_Template res_Template2 = ( from m in pm2Entities.Res_Template where m.TemplateId == cb.ToolTip select m).FirstOrDefault <Res_Template>(); if (res_Template2 != null) { pm2Entities.DeleteObject(res_Template2); pm2Entities.SaveChanges(); } } } } } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } base.RegisterScript("location.href=location.href;"); }
private void RemoveFromMapOverlay() { if (_overlayObject != null) { _overlayObject.Dispose(); _overlayObject = null; } }
public virtual void ResetIsNameFrank() { if (_IsNameFrankDisposable != null) { _IsNameFrankDisposable.Dispose(); } _IsNameFrankDisposable = _IsNameFrankProperty.ToComputed(ComputeIsNameFrank, this.GetIsNameFrankDependents().ToArray()).DisposeWith(this); }
private void ClearOverlay() { if (_overlayObject != null) { _overlayObject.Dispose(); _overlayObject = null; } }
public virtual void ResetPosition() { if (_PositionDisposable != null) { _PositionDisposable.Dispose(); } _PositionDisposable = GetPositionObservable().Subscribe(Entity.PositionProperty).DisposeWith(this); }
public void AddPrice() { string id = this.hdGuid.Value; if (!string.IsNullOrEmpty(this.resourceId)) { id = this.resourceId; } using (pm2Entities pm2Entities = new pm2Entities()) { IQueryable <Res_Price> queryable = from m in pm2Entities.Res_Price where m.ResourceId == id select m; foreach (Res_Price current in queryable) { pm2Entities.DeleteObject(current); } pm2Entities.SaveChanges(); } System.Collections.IEnumerator enumerator2 = this.gvwPriceType.Rows.GetEnumerator(); try { while (enumerator2.MoveNext()) { GridViewRow gridViewRow = (GridViewRow)enumerator2.Current; TextBox tb = gridViewRow.FindControl("txtPrice") as TextBox; using (pm2Entities pm2Entities2 = new pm2Entities()) { Res_Price res_Price = new Res_Price(); if (!string.IsNullOrEmpty(tb.Text)) { res_Price.PriceValue = System.Convert.ToDecimal(tb.Text); } Res_PriceType res_PriceType = ( from m in pm2Entities2.Res_PriceType where m.PriceTypeId == tb.ToolTip select m).First <Res_PriceType>(); res_PriceType.Res_Price.Add(res_Price); Res_Resource res_Resource = ( from m in pm2Entities2.Res_Resource where m.ResourceId == id select m).First <Res_Resource>(); res_Resource.Res_Price.Add(res_Price); pm2Entities2.AddToRes_Price(res_Price); pm2Entities2.SaveChanges(); } } } finally { System.IDisposable disposable = enumerator2 as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } }
protected void btnDel_Click(object sender, System.EventArgs e) { System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); bool flag = false; System.Collections.IEnumerator enumerator = this.gvResource.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { GridViewRow gridViewRow = (GridViewRow)enumerator.Current; CheckBox cb = gridViewRow.FindControl("cbBox") as CheckBox; if (cb != null && cb.Checked) { using (pm2Entities pm2Entities = new pm2Entities()) { IQueryable <Res_Resource> source = from m in pm2Entities.Res_Resource where m.Res_Unit.UnitId == cb.ToolTip select m; if (source.Count <Res_Resource>() > 0) { flag = true; break; } list.Add(cb.ToolTip); } } } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } if (flag) { base.RegisterScript("alert('系统提示:\\n\\n请先删除子项!')"); return; } foreach (string item in list) { using (pm2Entities pm2Entities2 = new pm2Entities()) { Res_Unit entity = ( from m in pm2Entities2.Res_Unit where m.UnitId == item select m).First <Res_Unit>(); pm2Entities2.DeleteObject(entity); pm2Entities2.SaveChanges(); } } base.RegisterScript("location.href=location.href;"); }
private void TryStopSeLoop() { if (seLoopDisposable == null) { return; } seLoopDisposable.Dispose(); seLoopDisposable = null; }
public void Dispose() { addDisposable.Dispose(); removeDisposable.Dispose(); clearDisposable.Dispose(); addDisposable = null; removeDisposable = null; clearDisposable = null; }
private void Unsubscribe() { elements.Clear(); lastDisposed.Dispose(); lastDisposed2.Dispose(); lastDisposed3.Dispose(); superAdd.Dispose(); superRemove.Dispose(); superClear.Dispose(); isSubscribed = false; }
protected void btnSave_Click(object sender, System.EventArgs e) { int year = System.Convert.ToInt32(this.hfldYear.Value.Trim()); int month = System.Convert.ToInt32(this.hfldMonth.Value.Trim()); System.Collections.IEnumerator enumerator = this.gvwSaMonth.Rows.GetEnumerator(); try { while (enumerator.MoveNext()) { GridViewRow gridViewRow = (GridViewRow)enumerator.Current; string id = gridViewRow.Attributes["id"].ToString(); for (int i = 6; i < gridViewRow.Cells.Count; i++) { TextBox textBox = (TextBox)gridViewRow.Cells[i].Controls[0]; if (textBox != null) { string ItemId = textBox.Attributes["itemId"]; string id2 = "hfld" + ItemId; decimal cost = 0m; string value = ((HiddenField)gridViewRow.Cells[i].FindControl(id2)).Value; if (!string.IsNullOrEmpty(value.Trim())) { cost = System.Convert.ToDecimal(value.Trim()); } SAMonthSalary sAMonthSalary = ( from sms in this.saMonthService where sms.UserCode == id && sms.ItemId == ItemId && sms.Year == year && sms.Month == month select sms).FirstOrDefault <SAMonthSalary>(); if (sAMonthSalary != null) { sAMonthSalary.ItemId = ItemId; sAMonthSalary.UserCode = id; sAMonthSalary.Cost = cost; this.saMonthService.Update(sAMonthSalary); } } } } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } base.RegisterShow("系统提示", "保存成功!"); this.BindGV(); }
public override void Run(object sender, System.EventArgs e) { RenderControlEditServices.Instance().StopGeometryEdit(true); System.DateTime temproalTime = System.DateTime.Now; if (CommonUtils.Instance().EnableTemproalEdit) { using (DateSettingDialog dateSettingDialog = new DateSettingDialog()) { if (dateSettingDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } temproalTime = dateSettingDialog.Time; } } DF3DFeatureClass featureClassInfo = null; System.Collections.IEnumerator enumerator = SelectCollection.Instance().FeatureClassInfoMap.Keys.GetEnumerator(); try { if (enumerator.MoveNext()) { DF3DFeatureClass featureClassInfo2 = (DF3DFeatureClass)enumerator.Current; featureClassInfo = featureClassInfo2; } } finally { System.IDisposable disposable = enumerator as System.IDisposable; if (disposable != null) { disposable.Dispose(); } } if (featureClassInfo == null) { return; } int count = SelectCollection.Instance().GetCount(false); EditParameters editParameters = new EditParameters(featureClassInfo.GetFeatureClass().Guid.ToString()); editParameters.connectionInfo = CommonUtils.Instance().GetCurrentFeatureDataset().DataSource.ConnectionInfo.ToConnectionString(); editParameters.datasetName = CommonUtils.Instance().GetCurrentFeatureDataset().Name; editParameters.TemproalTime = temproalTime; IBatcheEdit batcheEdit = BatchEditFactory.CreateBatchEdit(count); batcheEdit.BeginEdit(); batcheEdit.DoWork(EditType.ET_DELETE_SELCTION, editParameters); batcheEdit.EndEdit(); }
static StackObject *Dispose_0(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 1); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); System.IDisposable instance_of_this_method = (System.IDisposable) typeof(System.IDisposable).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); instance_of_this_method.Dispose(); return(__ret); }
/// <summary> /// Disposes of object resources. /// </summary> /// <param name="disposeManagedResources">If true, managed resources should be /// disposed of in addition to unmanaged resources.</param> protected virtual void Dispose(bool disposeManagedResources) { if (disposeManagedResources) { apiContext.Dispose(); if (Form.IsDisposed == false) { Form.Dispose(); } Fps.Dispose(); MeshFactory.Dispose(); PhysicsContext.Dispose(); } }
/// <summary> /// Closes the given stream. The same as calling <seealso cref="Closeable.close()"/>, but /// errors while closing are silently ignored. /// </summary> public static void closeSilently(System.IDisposable closeable) { try { if (closeable != null) { closeable.Dispose(); } } catch (IOException ignore) { LOG.debugCloseException(ignore); } }
public static void closeSilently(System.IDisposable closeable) { try { if (closeable != null) { closeable.Dispose(); } } catch (Exception) { // ignored } }
protected override void Dispose(bool disposing) { if (disposing) { apiContext.Dispose(); if (Form.IsDisposed == false) { Form.Dispose(); } Info.Dispose(); _meshFactory.Dispose(); } base.Dispose(disposing); }
public void Dispose() { if (Stream != null) { Stream.Dispose(); } if (_response != null) { _response.Dispose(); } if (_client != null) { _client.Dispose(); } }
private static void SafeClose(System.IDisposable closeable) { if (closeable != null) { try { closeable.Dispose(); } catch (IOException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } } }
private void CloseCurrentLogIfAny() { if (_closable != null) { try { _closable.Dispose(); } catch (IOException exception) { _debugLog.warn("Failed to close current log: " + _closable, exception); } _closable = null; } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void close() throws java.io.IOException public override void Close() { _closed = true; try { join(); } catch (InterruptedException e) { throw new IOException(e); } finally { _actual.Dispose(); } }