如何使用fbwf函数“FbwfCacheThresholdNotification”在C#中 [英] How to use the fbwf function "FbwfCacheThresholdNotification" in C#
问题描述
大家好,
我试图使用微软fbwf库的FbwfCacheThresholdNotification功能。该库在嵌入式Windows XP中使用,我认为它不适用于普通的Windows。文档可以在这里找到: [ ^ ]
文档对我来说不够。我可以使用哪种托管类型来处理?
目前我尝试了以下内容:
创建代理类型:
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
delegate void ThresholdNotificationDelegate();
传递委托给非托管函数:
[DllImport(fbwflib.dll,CallingConvention = CallingConvention.Winapi)]
静态extern UInt32 FbwfCacheThresholdNotification(UInt32阈值,[MarshalAs( UnmanagedType.FunctionPtr)] ThresholdNotificationDelegate thresholdNotification)
当我调用函数时,我得到6作为返回值,这意味着无效句柄。
感谢您的帮助!
Hello all,
I tried to use the function "FbwfCacheThresholdNotification" of the fbwf library of microsoft. The library is used in windows XP embedded and doesn't work on normal windows I guess. The documentation can be found here: [^]
The documentation is insufficient for me. What managed type can I use for handle?
Currently I tried the following:
Create a delegate of type:
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
delegate void ThresholdNotificationDelegate();
Passing that delegate to the unmanaged function:
[DllImport("fbwflib.dll", CallingConvention = CallingConvention.Winapi)]
static extern UInt32 FbwfCacheThresholdNotification(UInt32 threshold, [MarshalAs(UnmanagedType.FunctionPtr)] ThresholdNotificationDelegate thresholdNotification)
When I call the function I get "6" as return value, that means "invalid handle".
Thanks for your help!
推荐答案
参数是一个事件句柄。尝试将声明更改为:
The argument is an event handle. Try changing the declaration to:
[DllImport("fbwflib.dll", CallingConvention = CallingConvention.Winapi)]
static extern UInt32 FbwfCacheThresholdNotification(UInt32 threshold, Microsoft.Win32.SafeHandles.SafeWaitHandle thresholdNotification);
您应该能够创建一个新的 AutoResetEvent
(或 ManualResetEvent
)并将其 SafeWaitHandle
属性传递给该函数。当缓存低于阈值时,将发出该事件的信号。
You should then be able to create a new AutoResetEvent
(or a ManualResetEvent
) and pass its SafeWaitHandle
property to the function. That event will then be signalled when the cache falls below the threshold.
这篇关于如何使用fbwf函数“FbwfCacheThresholdNotification”在C#中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!