如果条件发生变化,则在执行某些操作时终止线程

时间:2016-03-23 12:40:26

标签: c# multithreading

我没有找到这种情况的确切情况。我搜索了SO,每个例子似乎都想完成他们先做的事情。是否有一个事件样式thread.terminate命令,允许我关闭一个线程,即使它当前正在进行数据库调用?我的意思不是:

public void threadhere()
{
    while (!variable)
    {
        do something;
    }
    end thread;
}

我的意思更像是:

public void threadhere
{
    making a database call and the condition changes while querying database
    so I will stop doing what I am doing and terminate the thread
}

0 个答案:

没有答案