dispose Questions

4

Solved

Say I have a non-sealed class that does not deal with any unmanaged resources. I need to make a single async call during its disposing stage to do some clean up. There are no other managed resource...
Eldoneldora asked 1/7, 2022 at 11:22

11

I need to force the use of "using" to dispose a new instance of a class. public class MyClass : IDisposable { ... } using(MyClass obj = new MyClass()) // Force to use "using" { }
Dikdik asked 20/4, 2010 at 13:38

3

Solved

I call my stateful widget page and get some info from the server. If no info found it warns the user that there isn't any info. From the drawer back button, I go back to the previous page. If I kee...
Copula asked 12/9, 2018 at 6:18

8

Solved

When would I implement IDispose on a class as opposed to a destructor? I read this article, but I'm still missing the point. My assumption is that if I implement IDispose on an object, I can expl...
Diffractometer asked 3/12, 2008 at 23:4

4

Solved

MSDN documents the thread-safety of instances members of BCL types pretty well, but I have never really seen information indicating how the Dispose method of IDisposable types can be called. Is th...
Marelda asked 17/2, 2011 at 3:52

2

Solved

When my stateless widget built I play some sounds in sequence order by using this code: await _audioPlayer.play(contentPath1, isLocal: true); await Future.delayed(Duration(seconds: 4)); await _aud...
Freud asked 21/10, 2018 at 17:10

2

Solved

I've been familiarizing myself with some of the things (that are planned to be) added in C# 8 & .NET Core 3.0, and am unsure on the correct way to implement IAsyncDisposable (at time of writing...
Sheritasherj asked 14/4, 2019 at 16:19

1

I dispose my observable in onPause(), and I would like to restart it in onResume(). How can I do that? Here is my observable: Observable<ObdCommandResult> myObservable = Observable.create(...
Tiv asked 6/11, 2017 at 20:12

5

Solved

I have a multi-threaded application and a CancellationToken is used as a shared object. Every thread can trigger it to tell the other threads the job is cancelled. Then one thread does the clean-up...
Lillis asked 13/4, 2011 at 20:40

2

Solved

I'm calling the following method in a loop while it is true, which leads to automatic reconnection. Since I'm using the using keyword, does it dispose the ClientWebSocket on each try/catch return f...
Kvass asked 21/4, 2022 at 10:33

12

Solved

Do you need to dispose of objects and set them to null, or will the garbage collector clean them up when they go out of scope?
Dismal asked 28/5, 2010 at 5:45

19

Solved

I am having List object. How can I dispose of the list? For example, List<User> usersCollection =new List<User>(); User user1 = new User(); User user2 = new User() userCollection.Ad...
Playbook asked 6/7, 2011 at 11:27

2

Solved

does anyone have any idea of how I can do this? My code: @override void dispose() { final FiltersBloc filtersBloc = BlocProvider.of<FiltersBloc>(context); super.dispose(); } error...
Modillion asked 19/10, 2019 at 14:30

3

Probably a Unity beginner's question: when using Unity, would you still need to implement Dispose methods on the objects you have injected? Or is even this not needed (so, done automatically by Uni...
Windtight asked 27/11, 2012 at 10:1

16

Solved

Why do some people use the Finalize method over the Dispose method? In what situations would you use the Finalize method over the Dispose method and vice versa?
Dictum asked 9/4, 2009 at 5:0

7

Solved

If I have a method like this: public void Show() { Form1 f = new Form1(); f.ShowDialog(); } Do I still need to call dispose on the form even though it will go out of scope, which will be eligi...
Guardrail asked 12/7, 2012 at 14:39

9

Solved

I'm new to C#, so apologies if this is an obvious question. In the MSDN Dispose example, the Dispose method they define is non-virtual. Why is that? It seems odd to me - I'd expect that a child cl...
Stubblefield asked 1/9, 2010 at 15:4

9

Solved

Let's say I have a class that implements the IDisposable interface. Something like this: MyClass uses some unmanaged resources, hence the Dispose() method from IDisposable releases those resourc...
Rachele asked 30/12, 2008 at 12:14

8

Is there a method, or some other light-weight way, to check if a reference is to a disposed object? P.S. - This is just a curiousity (sleep well, not in production code). Yes, I know I can catch t...
Frit asked 10/10, 2008 at 16:44

2

Solved

everyone. I have been stuck here dealing with this bugs for days, but I still couldn't figure it out. My guess: I think my code has some problem as I did not dispose the object properly after usin...
Shuttle asked 16/7, 2014 at 0:55

5

Solved

Does the garbage collector clean up web service references or do I need to call dispose on the service reference after I'm finished calling whatever method I call?
Cyr asked 9/1, 2009 at 19:58

1

Solved

I want to create a ZipArchive file if it doesn't already exist. Then I want to open it for reading its information before I update it. So is this valid use of the discard variable _ and does ...
Abyssinia asked 26/4, 2021 at 23:5

3

Solved

I'm using the ExchangeService WebService API (Microsoft.Exchange.WebServices.Data) but I cannot find any Close or Dispose method. Is it not neccessary to close the connection somehow? My method ...
Empirical asked 9/2, 2012 at 11:17

4

I'm asking this from an Android perspective, but this should apply to RxJava in general. As a best practice, should my view always dispose of even short lived Completable, Single, Maybe and termin...
Augie asked 27/9, 2017 at 20:18

4

Solved

I'm working in C# and my workplace has some code standards. One of them is that each event handler we connect (such as KeyDown) must be disconnected in the Dispose method. Is there any good reason ...
Ultan asked 1/7, 2013 at 8:15

© 2022 - 2024 — McMap. All rights reserved.