I usually declare the threads inside the using statement to make sure the thread is configured correctly when I finish with it, and therefore I will not mistakenly name it when I'm outside the used block.
Some examples here: MSDN using documentation help
How to use using statement with array of threads? Would it be tantamount to declaring an array outside the try / catch / finally block and calling each method to delete the stream in the finally block?
Finally, how to check if the threads are configured correctly?
I would create a new object that contains threads. Something like this (not fully specified):
class StreamHolder : IDisposable { List<Stream> Streams {get;} public void Dispose() { Streams.ForEach(x=>x.Dispose()): } }
- using, . - finally, , , , ,
using
, using using.
, Dispose ( , IDisposable, ). finally.
Dispose
IDisposable
finally
, . Dispose, , .
using() - , , . , .
, , , , using(), , encocassing finally .
, , Stream - , , /, IDisposable , Close/Dispose, .
Source: https://habr.com/ru/post/1753907/More articles:Hudson, customizing an individual default view - hudsonSpring servlet for serving static content? - javaAre locales global in perl? - formatIs there a way to determine if the Sense user interface is working on the device? - androidStrongly typed property reference to several classes without a common interface (C #) - polymorphismObjective-C: How to use xAuth? - objective-cTools and processes for managing application configuration - oracleHow to optimize this method - reflectionchmod() и chown() файла symlink в PHP - filesystemsКак не передавать файлы cookie в ExtJS HTTPRequest - javascriptAll Articles