Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Where to initialize IDisposable resource - within data class or data-object-list holders class
    primarykey
    data
    text
    <p>I need to pick up many video files from a directory and split them into audio and video (by ffmpeg) and convert into mxf and encrypt by third party (open source) command line tools. On encryption the tool generates keys and writes them into files with random names. So I need a background-worker (<strong>BGW</strong>) and a file-watcher (<strong>FW</strong>) (both of them has a dispose method so I believe they are linked to unmanaged resources and should be disposed after use). I have created a class - DrmConvertible (<strong>DC</strong>) which has reference to original video path and on a function call it does what I need as mentioned above (model). There is another class which reads all files from the directory and creates a list of DC object (like viewModel but not exactly). </p> <hr> <p>Where should I declare the FW and BGW ? </p> <ol> <li>Inside the DC class (maintains encapsulation but every object has an instance of it - may be 1000s).</li> <li>If point-01 then should it be global and initialized in constructor - it goes out of scope with the class (I don't know when).</li> <li>If point-01 then should it be local within the function and I explicitly initialize and dispose it within the function (do I also register and unregister events).</li> <li>In the class (global) and static variable so that only one instance is maintained and it goes out of scope with class (I don't know when). It is the same as abstracting it in a helper class or service and initializing once. </li> <li>In the outer class (viewmodel which has the list of DC objects - it breaks encapsulation but easier - in the current context) ? </li> </ol> <p>Is there a guideline for such a situation (what should go in data holder and what should go in the data-list holder) ? Please don't ask me to read the book code-complete [ ;) ]</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload