dispose Questions

6

When I run code analysis on the following chunk of code I get this message: Object 'stream' can be disposed more than once in method 'upload.Page_Load(object, EventArgs)'. To avoid generating a Sy...
Perrone asked 20/10, 2010 at 22:4

5

Solved

I am using C#. Is it advised to unit test dispose methods? If so why, and how should one test these methods?
Kissie asked 15/7, 2010 at 19:55

6

Solved

I am working to a VB.NET windows forms projet in .NET 1.1. And I have this type of architecture, very simplified. Public MustInherit Class BaseTestLogic Private _TimerPoll As Timer Public Sub ...
Vorous asked 27/4, 2010 at 12:45

5

Solved

I am relatively new to WPF, and some things with it are quite foreign to me. For one, unlike Windows Forms, the WPF control hierarchy does not support IDisposable. In Windows Forms, if a user contr...
Ratel asked 11/10, 2009 at 8:56

12

Solved

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 actual...
Aircool asked 26/5, 2009 at 23:8

3

Solved

I am trying to develop a Windows Mobile 6 (in WF/C#) application. There is only one form and on the form there is only a PictureBox object. On it I draw all desired controls or whatever I want. T...
Ringe asked 11/5, 2010 at 7:21

3

Solved

I am receiving data from UdpClient via the usual async callback: private void OnUdpData(IAsyncResult result) { byte[] data = _udpReceive.EndReceive(result, ref _receiveEndPoint); //Snip doing s...
Diphthongize asked 16/2, 2012 at 11:23

4

Solved

im using ZXing.Net.Mobile for Forms like this var scanPage = new ZXingScannerPage(); scanPage.OnScanResult += (result) => { // Stop scanning scanPage.IsScanning = false; // Pop the page ...
Classicize asked 29/12, 2016 at 15:20

7

Solved

Naturally, BeginReceive() will never end if there's no data. MSDN suggests that calling Close() would abort BeginReceive(). However, calling Close() on the socket also performs a Dispose() on it, a...
Phyllisphylloclade asked 11/1, 2011 at 20:55

3

Solved

I was refactoring some the other day, I bumped into something like that: public async Task<Result> Handle(CancelInitiatedCashoutCommand command, CancellationToken cancellationToken) { using...
Ferity asked 11/12, 2019 at 11:41

4

Solved

Can I use this approach efficiently? using(SqlCommand cmd = new SqlCommand("GetSomething", new SqlConnection(Config.ConnectionString)) { cmd.Connection.Open(); // set up parameters and CommandTy...
Statius asked 13/9, 2008 at 22:10

2

Solved

I working on android project with clean architecture. I have the below class: public abstract class RxBaseInteractor<T, Params> { private final CompositeDisposable disposables; public R...
Subjunction asked 3/11, 2017 at 21:58

2

Solved

I have a class that owns a CancellationTokenSource. public class GrabboxCell : UICollectionViewCell { CancellationTokenSource _tokenSource = new CancellationTokenSource (); // ... } I'm using...
Tetraspore asked 2/2, 2013 at 10:58

4

Solved

So my requirement is to have my function wait for the first instance an event Action<T> coming from another class and another thread, and handle it on my thread, allowing the wait to be inter...
Reprieve asked 14/7, 2013 at 0:30

1

I have a tabbed Flutter interfaces using DefaultTabController with 3 pages, each a stateful widget. I seem to be able to switch between the first two tabs just fine, but when I tab to the 3rd page ...
Blasien asked 25/4, 2019 at 13:41

4

I've read carefully through this article and it seems to clearly state that the dispose pattern should be implemented in all cases of IDisposable implementation. I'm trying to understand why I need...
Diaz asked 16/4, 2019 at 16:0

6

Solved

I usually use code like this: using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString)) { var command = connection.CreateCommand(); command.Co...
Goshen asked 27/11, 2009 at 10:47

1

Solved

I'm using TaskCompletionSource in my software to distribute network packets to async/await methods. So in my code, there are various points where the software needs to wait for a network packet get...
Mika asked 18/2, 2019 at 21:49

0

This is a follow-up question from this one. Specifically I'm trying to verify correct use of an API which involves calling close() on Java objects holding heavy native resources over JNI. To re-it...
Moonstone asked 12/2, 2019 at 14:1

5

I am authoring a java library. Some of the classes that are meant to be used by library users, hold native system resources (over JNI). I'd like to ensure that the user "disposes" these objects, as...
Antisyphilitic asked 29/1, 2019 at 19:44

2

Solved

Is Discards feature correctly works with IDisposable objects? Is it call Dispose(); when its needed? I have a code: Boolean existing = Mutex.TryOpenExisting(name: key, rights: MutexRights.Read...
Flinger asked 15/12, 2018 at 17:58

6

Solved

Often I find myself writing code like this: if (Session != null) { Session.KillAllProcesses(); Session.AllUnitsReady -= Session_AllUnitsReady; Session.AllUnitsResultsPublished -= Session_AllU...
Rotatory asked 15/7, 2010 at 17:6

3

Solved

I need some advice on the implementation of the Dispose method. In our application the user designs their own UI. I have a preview window that shows what the UI is going to look like. All object d...
Antony asked 20/9, 2011 at 12:23

3

Solved

There are multiple threads(a, b, c etc.) about the fact that Clear() ing items in the .NET component containers does not Dispose them(by calling Dispose(true). Most frequently, IMHO, the Clear-ed ...
Darrickdarrill asked 28/12, 2009 at 14:29

3

Solved

Does the using statement always dispose the object, even if there is a return or an exception is thrown inside it? I.E.: using (var myClassInstance = new MyClass()) { // ... return; } or usin...
Griffith asked 28/6, 2013 at 4:36

© 2022 - 2024 — McMap. All rights reserved.