EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Disposing the filter object

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#34671
Posted: 10/08/2015 08:24:13
by Chris Spiteri (Standard support level)
Joined: 10/06/2014
Posts: 57

Hello,

I have a question on how to implement the filter uninitialization.

The object in our code that wraps the filter object implements IDisposable. Our Dispose implementation follows the design pattern recommended by Microsoft (https://msdn.microsoft.com/en-us/library/fs2xkftw(v=vs.110).aspx), i.e. a conditional block that disposes the managed resources, and a block that disposes the unmanaged resources.

Should the filter calls DetachFilter and Dispose be placed in the block that disposed the managed resources, or the block that disposes the unmanaged resources?

Thanks and regards,
Chris
#34672
Posted: 10/08/2015 08:37:06
by Eugene Mayevski (EldoS Corp.)

I think it should be the same as disposal of FileStream objects. There are unmanaged objects being disposed of inside, so it's probably an Unmanaged block.


Sincerely yours
Eugene Mayevski
#34674
Posted: 10/08/2015 08:48:18
by Chris Spiteri (Standard support level)
Joined: 10/06/2014
Posts: 57

Apologies, but i did not quite understand :)

Can you explaing this: "There are unmanaged objects being disposed of inside, so it's probably an Unmanaged block." Does it mean that i should call Filter.Dispose() from the unmanaged block? Or does it mean that Dispose should be called the same as if i am disposing FileStream's?

Thanks,
Chris
#34675
Posted: 10/08/2015 08:55:13
by Eugene Mayevski (EldoS Corp.)

I don't understand either ;) -- I am just speculating.

CallbackFilter class itself is managed. But it releases unmanaged resources internally, and it performs other global objects. So I think that it's better to dispose of it in Unmanaged block.


Sincerely yours
Eugene Mayevski
#34676
Posted: 10/08/2015 08:58:40
by Chris Spiteri (Standard support level)
Joined: 10/06/2014
Posts: 57

Ok thanks a lot :)

Best regards,
Chris
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

Topic viewed 4197 times

Number of guests: 2, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!