开发者

Detect when users log out of an application in C#

开发者 https://www.devze.com 2022-12-18 00:17 出处:网络
If the application I\'m working on, is there any way to tell when users press the Logout butt开发者_如何学Con?I\'m familiar with the paradigmatic differences between WPF and Winforms, but haven\'t eve

If the application I'm working on, is there any way to tell when users press the Logout butt开发者_如何学Con?


I'm familiar with the paradigmatic differences between WPF and Winforms, but haven't ever written a line of WPF code, so this may not be applicable, but... The way to accomplish this in WinForms would be to create a method on C (by subclassing C if it's not a class you can modify) and subscribing that method to the Click event on the button during your form's Load event handler.


If form F has a reference to C, the F click handler can call a method on C.

If form F doesn't have a reference to C, expose a LoggedOut event on the first form, and either subscribe to it from C (if C has a reference to F) or use an event aggregator if C neither has a reference to the other.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号