主窗口在WPF中关闭时取消后台工作程序

问题描述:

在我的WPF应用程序中,



在此应用程序中,我使用的是一个用户控件。



在用户控制按钮单击事件中,我们正在启动一个后台工作。



在后台工作程序中,我们将一些数据导出到.Csv文件。



当这个过程正在运行时,我们需要在用户关闭主窗口时取消后台工作人员。



我的问题是我们如何用户关闭窗口时可以停止。



请提供您的想法。

In My WPF application,

In this Application i am using One user control.

In the user control button click event we are starting one backgroundworker.

In the background worker we are exporting some data to the .Csv file.

While this process is running we need to cancel the background worker when the user close the mainwindow.

My question is how we can stop when user closes the window.

Please provide me your ideas.

使用窗口WPF中存在已关闭的事件并编写代码(您想要停止的过程。)。
use the Window closed event present in WPF and write the code (the process you wanted to stop.).