flfq
25995
|
2006/9/11 15:25:04 |
如果看而不顶,那肯定不是个人 |
blbz
25915
|
2006/9/7 13:36:27 |
unit HTTPtask 有BUG |
chinafox2003
25824
|
2006/9/2 18:43:06 |
如果更改的话没有效果吗? |
dejoy
25706
|
2006/8/28 15:45:50 |
多线程用在数据库中不是用来更改数据,只是用来查询,查询不用事务 |
chinafox2003
25675
|
2006/8/26 14:10:32 |
99koo大师,您看看我的代码: 这个市创建线程单元: unit MyThread;
interface uses Classes,StdCtrls,Windows,SysUtils,IdHTTP,dialogs, Forms,main; type TAddNews=class(TThread) private newscaption,newsurl:string; protected public constructor Create(tempcaption,tempurl: string); procedure Execute;override; procedure AddNews; end;
implementation
constructor TAddNews.Create(tempcaption,tempurl: string); begin newscaption := tempcaption; newsurl:=tempurl;// 传递参数 FreeOnTerminate := True; // 自动删除 //InitializeCriticalSection(CS); //初始化临界区 inherited Create(False); // 直接运行 end; procedure TAddNews.AddNews; var logininfo:Tstringlist; AddNews: TidHttp; begin if (newscaption ='') or (newsurl ='') then begin application.MessageBox('标题和链接不得为空','提示',mb_ok+mb_iconinformation); exit; end; logininfo:=TStringlist.Create; LoginInfo.Add('caption='+trim(newscaption)); LoginInfo.Add('url='+trim(newsurl)); try AddNews:=Tidhttp.Create(nil); AddNews.HandleRedirects:=true; AddNews.Post('http://www.baidutong.com/mynews/PostNews.asp',LoginInfo); application.MessageBox('添加成功','提示',mb_ok+mb_iconinformation); except showmessage('添加失败'); end; frmmain.newscaption.Text :=''; frmmain.newsUrl.Text :=''; logininfo.Free; AddNews.free; end; procedure TAddNews.Execute; begin self.Synchronize(AddNews); end; end. 这是调用: procedure TfrmMain.RzBitBtn3Click(Sender: TObject); var NewsAdd:TAddNews; begin NewsAdd:=TAddNews.Create(trim(newscaption.Text),trim(newsurl.Text)); NewsAdd.Resume; end; 为什么起不到线程作用? |
lufangyu
25673
|
2006/8/26 13:16:47 |
多线程技术应用于数据库不太适合,因为数据有事务要处理 |
dejoy
25672
|
2006/8/26 12:52:42 |
这个只能用于网络编程吗?能否用于数据库或其它操作? |
zhude
25670
|
2006/8/26 10:56:56 |
支持楼主....不错不错 |
99koo
25664
|
2006/8/26 9:37:44 |
把类的代码贴出来,我可以帮你看一下 |
chinafox2003
25662
|
2006/8/26 8:20:19 |
高手,你好,我在线程中使用idhttp添加数据到网站,虽然用了线程,但是只要一点击添加按钮,主程序还是没反应,要等添加完后才能恢复,请问怎么回事? |
![]() |
|