简体   繁体   English

在C#中实现后台工作者类

[英]Implement Background Worker Class in C#

I am working on an application which is guest house management system.it works fine but what i want is to embed the background worker class in my project. 我正在开发一个应用程序,它是旅馆管理系统。它工作正常,但我想要在我的项目中嵌入后台工作者类。

here is how it looks 这是它的样子 在此处输入图片说明

I want list of rooms to be updated automatically on saving the information on the Add room form.For displaying room i am using grid-view and for adding new room i created a new form and add LINQ to SQL query code to save the information of new room. 我希望在添加房间表单上保存信息后自动更新房间列表。为了显示房间,我正在使用网格视图并添加新房间,我创建了一个新表单,并将LINQ添加到SQL查询代码以保存以下信息:新房间。

How should i go about it in C#. 我应该如何在C#中进行处理。 Any alternate suggestion would also be appreciated. 任何其他建议也将不胜感激。

You can create a new thread that is separated in your current thread. 您可以创建一个与当前线程分开的新线程。

Thread workerThread = new Thread(delegate()
{
// Perform your task here
});

and when you want to call it, just invoke the 当您要调用它时,只需调用

workerThread.Start();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM