Linked Questions

0 votes
1 answer
73 views

c# Blazor server transient services dispose

I am working on Blazor server application and I am blocked / confused about using transient type services inside Blazor server. I have readed this topic on why I should not implement IDisposable ...
0 votes
1 answer
90 views

Stream file, file in use, FileSystemWatcher and question about threads

I've been trying to create a script which takes the content of a text file which may look like this (1 line text in a .txt. file): SomeData SomeData SomeData and these files are dropped ...
2 votes
2 answers
63 views

Will an anonymous StreamReader close automatically?

I've found the following code in a project I'm working on and I'm curious to know if it can be written more succinctly. using (var stream = new FileStream(CustomSettingsFile.FullName, FileMode.Open, ...
198 votes
8 answers
91k views

What exactly are unmanaged resources?

I want to know about unmanaged resources. Can anyone please give me a basic idea?
-1 votes
1 answer
82 views

C# setting members from using statement

class A { TypeX PropertyX; void SomeMethod() { using (DisposableType y = new DisposableType()) { PropertyX = y.GetX(); } } } What happens to PropertyX when Y is being ...
7 votes
4 answers
5k views

Does C# app exit automatically dispose managed resources?

I am fully aware that using statements are the way to handle IDisposables. Please do not repeat this advice in comments. When a C# .NET 4.5 (or higher) application closes, what happens to the ...
1 vote
1 answer
179 views

.Net app using 1.3GB on system with 16GB RAM throws OutOfMemoryException

I have a process dump from a Windows 10 64-bit .Net Winforms application that suffered from a System.OutOfMemoryException. The dump file is 1.3GB. A managed profiler (dotMemory) says 220MB of heap is ...
-1 votes
1 answer
293 views

Set all properties to null is a valid way to dispose an object? [duplicate]

Using statement requires the object type to directly implement IDisposable. Looking for the easiest to do so, came up with this snippet. public class Foo : IDisposable { public string? ...
3 votes
1 answer
125 views

Do .NET finalizers have a timeout?

Edits - Renamed to finalizer per answer I am trying to do a few things in a finalizer, and the program terminates before I'm done. To simulate, I made the following test, which prints up to 20 Does ...
277 votes
16 answers
198k views

Finalize vs Dispose

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?
3 votes
4 answers
5k views

Details about inheriting IDisposable?

I've been tasked with going through some old code at work to clean it up and I stumbled across a class: public class XMLLayer : Object, IDisposable First I find that the explicit Object inheritance ...
0 votes
2 answers
112 views

Forbid to copy a variable

I have a class Foo which contains a pointer to unmanaged memory from C dll. It implements IDisposable to free unmanaged memory using C dll and some other functionality with that ptr using dll. public ...
-1 votes
1 answer
225 views

Properly removing COM objects from memory

I am creating a C# wrapper over the Acrobat SDK (yes, I know there are utilities out there already). I'm importing an Adobe type library that was created in C/C++. Perhaps this is obvious but I'm ...
0 votes
3 answers
3k views

Is Close() same as Using statement

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 ...
0 votes
0 answers
27 views

C# dispose unmanaged object stored in managed collection [duplicate]

In my class I have unmanaged objects in managed collection (pendingFramesBuffer). I need to implemented IDisposable interface. My question: Where I need to clear pendingFramesBuffer collection? In the ...

15 30 50 per page
1
2 3 4 5
11