S
Shaun Bedingfield
I am building a high-performance multi-threaded application.
I am making the following call in the code to convert a rasterized bitmap to
a bitmap source.
BitmapSource pageImageSource = Imaging.CreateBitmapSourceFromHBitmap(
bitmapHandle, IntPtr.Zero, Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
Based on the documentation and lack of comments, I was assuming the method
was thread safe, however, I start getting exceptions after about 48 hours of
operation at full load in my development area.
The following exception is caught:
Exception occurred: System.ComponentModel.Win32Exception: The system cannot
find the file specified
at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32
exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr
parent, HwndWrapperHook[] hooks)
at System.Windows.Threading.Dispatcher..ctor()
at System.Windows.Freezable..ctor()
at System.Windows.Media.Imaging.BitmapSource..ctor(Boolean useVirtuals)
at System.Windows.Interop.InteropBitmap..ctor(IntPtr hbitmap, IntPtr
hpalette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions,
WICBitmapAlphaChannelOption alphaOptions)
at
System.Windows.Interop.Imaging.CriticalCreateBitmapSourceFromHBitmap(IntPtr
bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions,
WICBitmapAlphaChannelOption alphaOptions)
at System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(IntPtr
bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions)
at
.....
Is my initial assumption about the thread-safety of the method correct? I
would hate to put a mutex around the code but I can if need be.
Is there another way to cause this exception to go away?
Thanks for any assistance
I am making the following call in the code to convert a rasterized bitmap to
a bitmap source.
BitmapSource pageImageSource = Imaging.CreateBitmapSourceFromHBitmap(
bitmapHandle, IntPtr.Zero, Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
Based on the documentation and lack of comments, I was assuming the method
was thread safe, however, I start getting exceptions after about 48 hours of
operation at full load in my development area.
The following exception is caught:
Exception occurred: System.ComponentModel.Win32Exception: The system cannot
find the file specified
at MS.Win32.UnsafeNativeMethods.RegisterClassEx(WNDCLASSEX_D wc_d)
at MS.Win32.HwndWrapper..ctor(Int32 classStyle, Int32 style, Int32
exStyle, Int32 x, Int32 y, Int32 width, Int32 height, String name, IntPtr
parent, HwndWrapperHook[] hooks)
at System.Windows.Threading.Dispatcher..ctor()
at System.Windows.Freezable..ctor()
at System.Windows.Media.Imaging.BitmapSource..ctor(Boolean useVirtuals)
at System.Windows.Interop.InteropBitmap..ctor(IntPtr hbitmap, IntPtr
hpalette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions,
WICBitmapAlphaChannelOption alphaOptions)
at
System.Windows.Interop.Imaging.CriticalCreateBitmapSourceFromHBitmap(IntPtr
bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions,
WICBitmapAlphaChannelOption alphaOptions)
at System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(IntPtr
bitmap, IntPtr palette, Int32Rect sourceRect, BitmapSizeOptions sizeOptions)
at
.....
Is my initial assumption about the thread-safety of the method correct? I
would hate to put a mutex around the code but I can if need be.
Is there another way to cause this exception to go away?
Thanks for any assistance