显示消息框后如何停止功能 [英] How to stop function once message box displayed

查看:71
本文介绍了显示消息框后如何停止功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public void CreateFileOutput(object parameter)
{
    TransactFileCreation();

    WPFMessageBox.Show("test", "Process completed successfully.");
}

public void TransactFileCreation()
{
    if (BatchFolderPath == null)
    {
         WPFMessageBox.Show("test", "Select a Batch folder");
         return;
    }
    // code..
}

我正在从CreateFileOutput()调用TransactFileCreation().显示消息框后,该功能将不再起作用.但就我而言,它再次转到主功能并显示其中的msg框.显示消息框后如何停止执行.为我提供解决方案.谢谢.

I am calling TransactFileCreation() from CreateFileOutput(). Once Msg Box displayed, further the function should not work. But in my case, it again go to the main function and displaying msg box present in that. How to stop execution after once message box is displayed. Provide me a solution. Thanks.

推荐答案

您可以返回布尔值:

public bool TransactFileCreation()
{
    if (BatchFolderPath == null)
    {
         WPFMessageBox.Show("test", "Select a Batch folder");
         return false;
    }
    // code..
    return true;
}

然后您这样调用:

public void CreateFileOutput(object parameter)
{
    if (!TransactFileCreation())
        return;

    WPFMessageBox.Show("test", "Process completed successfully.");
}

这篇关于显示消息框后如何停止功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆