I have a managed class that registers a window class with the usual Win32
RegisterClass API.
// Global function, not part of class
LRESULT
CALLBACK
MyWindowProc(
IN HWND hwnd,
IN UINT Msg,
IN WPARAM wParam,
IN LPARAM lParam
);
// Simplified example class
__gc public class MyClass
{
public: MyClass()
{
WNDCLASS wc;
wc.lpfnWndProc = MyWindowProc;
//...
RegisterClass(& wc);
}
}
Maybe I am overthinking this, but I assume that the "it just works"
mechanism will create a delegate on my behalf, since ViewportWindowP roc is a
managed function. My question is whether I need to worry about that delegate
getting collected because there's no reference to it; I don't see how I
would control the lifetime of that "behind the scenes" delegate. Do I need
to resort to manually handling the interop for a scenario like this? That
would be no problem, I just want to make sure I am understanding things. The
code as I've written it works, but I wouldn't want it to start failing under
load/stress in production.
RegisterClass API.
// Global function, not part of class
LRESULT
CALLBACK
MyWindowProc(
IN HWND hwnd,
IN UINT Msg,
IN WPARAM wParam,
IN LPARAM lParam
);
// Simplified example class
__gc public class MyClass
{
public: MyClass()
{
WNDCLASS wc;
wc.lpfnWndProc = MyWindowProc;
//...
RegisterClass(& wc);
}
}
Maybe I am overthinking this, but I assume that the "it just works"
mechanism will create a delegate on my behalf, since ViewportWindowP roc is a
managed function. My question is whether I need to worry about that delegate
getting collected because there's no reference to it; I don't see how I
would control the lifetime of that "behind the scenes" delegate. Do I need
to resort to manually handling the interop for a scenario like this? That
would be no problem, I just want to make sure I am understanding things. The
code as I've written it works, but I wouldn't want it to start failing under
load/stress in production.