I want send some data on server, before window close. I use event closing, but it doesn t wokr. Where is a problem?
private void Window_Closing(object sender
Try overriding OnClosing in the window code behind. There you have a chance to stop the window from closing if you have something else to do by setting e.Cancel = true
.
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
bool isClosed = _obj.CloseConnection();
if(!isClosed)
e.Cancel = true;
}
Did you check if there's a problem on _obj.CloseConnection()? Try to debug your code and check if the event handler is called.