Hi,
if you're having troubles with the casting to an interface type, then you can use this:

1
2
(gr.Target :> IDisposable).Dispose()
(context :> IDisposable).Dispose()

F# makes a distinction between upcast (:>), which is a cast that cannot fail and a downcast (:?>), which ma fail (e.g. casting "System.Object" to "System.Random"). Anyway, there is also a nicer way for disposing resources:

1
2
use context = Gdk.CairoHelper.Create(...)
// will be disposed automatically at the end of the method (and wrapped in a "try ... finally" block)
By on 11/22/2008 4:08 AM ()

Hi Tomas,

Thanks a lot, both suggestions worked just fine. I especially appreciate the second one as it really makes the code much cleaner.

Cheers,
Piotr

By on 11/22/2008 2:49 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper