在asp.net winforms中处理线程 [英] handling threads in asp.net winforms

查看:56
本文介绍了在asp.net winforms中处理线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所有的人都有一个winform,其中m试图将数据从计数更新到服务器
database.tally的任何更改都会反映到server.i正在通过线程进行所有操作.现在,我想在单击菜单时显示来自server的datagrid中的数据.
它可以正常工作并在datagrid中显示数据,但有时在
中不显示数据 grid.i无法解决问题.告诉我我错了.... !!

hii all i have a winform in which m trying to update data from tally to server
database.any change in tally gets reflected to server.i am doing all this through threading.now i want to show the data in datagrid from server on clicking the menu.
Its working fine and shows data in datagrid but sometimes it does not show data in
grid.i cant figure out the problem.tell me where m i wrong....!!

if (thrd != null)
{
   if (thrd.ThreadState == ThreadState.Stopped || thrd.ThreadState == ThreadState.WaitSleepJoin || thrd.ThreadState == ThreadState.Aborted)
   {
      thrd = new Thread(new ThreadStart(startprocess));
      thrd.Start();
   }
   else
   {
      startprocess();
   }
}
else
{
   thrd = new Thread(new ThreadStart(startprocess));
   thrd.Start();
   }


在startproceess中,比较计数数据和服务器n的数据(如果对计数数据进行了任何更改,则会更新)
通过startprocess.This是后台进程.如果我喜欢菜单上的库存项目,现在位于前端.它在网格中显示数据.
但有时有时无法获得数据.


in startproceess m comparing the data of tally and server n if any change is made to tally data it gets updated
through startprocess.this is background process.now at front end if i clcik on menu stock item.it shows data in grid.
but the data is sometimes available sometimes not.

string query = "select * from Product_Master where Compid=(select Companyid from Company_Master where Companyname='" + txtuserid.Text + "')";
           
SqlDataAdapter da = new SqlDataAdapter(query, conn);
DataTable dt = new DataTable();
da.Fill(dt);
                
gridproduct.DataSource = dt;
              
panel4.Visible = true;

推荐答案

正如您所说的ASP.NET,我假设你的意思是网络表单.您不能在ASP.NET中启动线程,因为您的代码只会运行以生成页面,并且它不会等待线程运行.
As you said ASP.NET, I assume you mean webforms. You can''t be starting threads in ASP.NET, because your code only runs to generate a page, and it won''t wait for a thread to run.


这篇关于在asp.net winforms中处理线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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