Issue DataSet and DataTable both implement IDisposable, so, by conventional best practices, I should call their Dispose() methods. However, from what I’ve read so far, DataSet and DataTable don’t actually have any unmanaged resources, so Dispose() doesn’t actually do much.
Continue readingTag: dispose
New `using` syntax interaction with long lived references
Issue Here’s some example code; public sealed class HoldingClass : IDisposable { private BinaryReader _binaryReaderField; public string GetStringFromReader(int count) { var data = _binaryReaderField.ReadBytes(count); // … Process data … // return newString; } public void Dispose() { _binaryReaderField?.Close(); _binaryReaderField?.Dispose(); }
Continue readingIs Close() same as Using statement
Issue Is Close() same as Dispose() or using statement. Is it necessary to call using statement even if Close is called?. I know before disposing of an object, close should be called, so we close the resource and may it
Continue readingTry/Finally block vs calling dispose?
Issue Is there any difference between these two code samples and if not, why does using exist? StreamWriter writer; try { writer = new StreamWriter(…) writer.blahblah(); } finally { writer.Dispose(); } vs: using (Streamwriter writer = new Streamwriter(…)) { writer.blahblah
Continue readingC# .Net Framework Disposing of Tasks
Issue I was wondering if there are any benefits to implementing the dispose feature for Tasks. Will this operate any different? Will this force the memory to clean up any faster? Task updateTask = UpdateRemoteAsync() await updateTask; VS using (Task
Continue readingCan ZXing be stopped or dispose so i can use it again?
Issue im using ZXing.Net.Mobile for Forms like this var scanPage = new ZXingScannerPage(); scanPage.OnScanResult += (result) => { // Stop scanning scanPage.IsScanning = false; // Pop the page and show the result Device.BeginInvokeOnMainThread(async () => { // await Navigation.PopAsync(); await
Continue reading