Delphi线程的初级应用
viewRadio_th线程函数在form外生命全局变量、函数内相应的局部变量可以接收全局变量的赋值进行操作、query等可以自行创建进行查询、这样结果不会改变。 //下面是后台发送字幕的线程函数应用。 …… var
ldate,ldatetime:string;
lHandle:thandle;
dloopThreadID:dword;
message_form: Tmessage_form;
function viewRadio_th(P:pointer):Longint;stdcall; implementation
uses commonDM, ubox_c, common_u, loginform; …… //调用线程 lHandle := CreateThread(nil,0,@viewRadio_th,nil,0,dloopThreadID); //线程函数 function viewRadio_th(P:pointer):Longint;stdcall; var lquery,lnumquery:Toraquery;
I,j: Integer;
th_date,th_datetime:string;
th_handle:thandle;
th_loopThreadID:dword;
maxnum,boxid,boxip:string;
F:Textfile;
begin
th_date:=ldate;
th_datetime:=ldatetime;
th_handle:=lhandle;
th_loopThreadID:=dloopThreadID;
lquery:=Toraquery.Create(nil);
lnumquery:=toraquery.Create(nil);
lquery.FetchAll:=true;
lnumquery.Session:=common_dm.common_session;
lquery.Session:=common_dm.common_session;
with lnumquery do
begin
close;
sql.Clear;
sql.Add('select max(promotesalesplaynumber) maxnum from promotesales_t where PROMOTESALESTYPE=''?¤??'' and '''+
th_date+' ''||PROMOTESALESPLAYTIME='''+th_datetime+'''');
open;
end; // with
if lnumquery.RecordCount<>0 then
maxnum:=lnumquery['maxnum'];
with lquery do
begin
close;
sql.Clear;
sql.Add('select * from promotesales_t where PROMOTESALESTYPE=''?¤??'' and '''+
th_date+' ''||PROMOTESALESPLAYTIME='''+th_datetime+'''');
open;
end; // with
for I := 1 to strtoint(maxnum) do // Iterate
begin
lquery.First;
if i<>1 then
sleep(60000);
for j := 0 to lquery.RecordCount - 1 do // Iterate
begin
if strtoint(lquery['promotesalesplaynumber'])>=i then
begin
boxid:=lquery['promoteboxid'];
with lnumquery do
begin
Close;
SQL.Clear;
SQL.Add('select * from BOX_T where BOXID='''+boxid+'''');
Open;
end; // with
boxip:=lnumquery['boxip'];
if fileExists(common_u.fileaddress(boxip,'radioroot')+'.tit') then
Deletefile(common_u.fileaddress(boxip,'radioroot')+'.tit');
AssignFile(F, common_u.fileaddress(boxip,'radioroot')+'.tit'); {??????????±??? F ????}
ReWrite(F);
Writeln(F, '[Parameter]'+#13+'Delay=0'+#13+'IntoDelay=0'+#13+#13+'[TextAdOsd]'+
#13+'PlayMode=RIGHT_IN_LEFT_OUT'+#13+'Type=Text'+#13+'Font=????'+#13+'FontSize=40'+#13+'LoopTime=1'+#13+'Speed=5'
+#13+'Delay=0'+#13+'Time=0'+#13+'ForegroundColor=255 255 0'+#13+'BackgroundColor=0 0 0'+#13+'UseShadow=y'+#13+'ShadowColor=255 0 0'
+#13+'ShadowDelta=1 1'+#13+'cmd=first'+#13+'Text='+lquery['PROMOTESALESCONTENT']);
Closefile(F); {??±????? F}
end;
lquery.Next;
end; // for end; // for
lquery.Free;
lnumquery.Free;
if th_handle<>0 then
TerminateThread(th_handle,th_loopThreadID);
end;
Delphi线程的初级应用的更多相关文章
- TMsgThread, TCommThread -- 在delphi线程中实现消息循环
http://delphi.cjcsoft.net//viewthread.php?tid=635 在delphi线程中实现消息循环 在delphi线程中实现消息循环 Delphi的TThread类使 ...
- TMsgThread, TCommThread -- 在delphi线程中实现消息循环(105篇博客,好多研究消息的文章)
在delphi线程中实现消息循环 在delphi线程中实现消息循环 Delphi的TThread类使用很方便,但是有时候我们需要在线程类中使用消息循环,delphi没有提供. 花了两天的事件研究了 ...
- delphi 线程教学第六节:TList与泛型
第六节: TList 与泛型 TList 是一个重要的容器,用途广泛,配合泛型,更是如虎添翼. 我们先来改进一下带泛型的 TList 基类,以便以后使用. 本例源码下载(delphi XE8版本) ...
- Delphi线程定时器TThreadedTimer及用法--还有TThreadList用法可以locklist
Delphi线程定时器 - -人生如歌- - 博客园http://www.cnblogs.com/zhengwei0113/p/4192010.html (* 自己编写的线程计时器,没有采用消息机制, ...
- delphi 线程教学第二节:在线程时空中操作界面(UI)
第二节:在线程时空中操作界面(UI) 1.为什么要用 TThread ? TThread 基于操作系统的线程函数封装,隐藏了诸多繁琐的细节. 适合于大部分情况多线程任务的实现.这个理由足够了吧 ...
- delphi 线程教学第一节:初识多线程
第一节:初识多线程 1.为什么要学习多线程编程? 多线程(多个线程同时运行)编程,亦可称之为异步编程. 有了多线程,主界面才不会因为耗时代码而造成“假死“状态. 有了多线程,才能使多个任务同时 ...
- 多线程的基本概念和Delphi线程对象Tthread介绍
多线程的基本概念和Delphi线程对象Tthread介绍 作者:xiaoru WIN 98/NT/2000/XP是个多任务操作系统,也就是:一个进程可以划分为多个线程,每个线程轮流占用CPU运行 ...
- Delphi线程的终止
当线程对象的Execute()执行完毕,我们就认为此线程终止了.这时候,它会调用Delphi的一个标准例程EndThread(),这个例程再调用API函数ExitThread().由ExitThrea ...
- Delphi线程基础知识
参考http://blog.chinaunix.net/uid-10535208-id-2949323.html 一.概述 Delphi提供了好几种对象以方便进行多线程编程.多线程应用程序有以下几方面 ...
随机推荐
- 使用SAS令牌连接Azure EventHub
概述 事件中心使用在命名空间和事件中心级别提供的共享访问签名.SAS令牌是从SAS密钥生成的,它是以特定格式编码的URL的SHA哈希. 事件中心可以使用密钥(策略)的名称和令牌重新生成哈希,以便对发送 ...
- BZOJ 2792 Poi2012 Well 二分答案
题目大意:给定一个非负整数序列A.每次操作能够选择一个数然后减掉1,要求进行不超过m次操作使得存在一个Ak=0且max{Ai−Ai+1}最小,输出这个最小值以及此时最小的k 二分答案,然后验证的时候首 ...
- pouchdb快速入门教程
a:focus { outline: thin dotted #333; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2p ...
- sublime text3 修改左边栏背景颜色为编辑栏颜色
用Package Control安装Theme-Afterglow插件: Ctrl+Shift+P -> install ,如图 点击Install Package,在弹出框中输入Theme-A ...
- Silverlight实例教程 - Validation用户提交数据验证捕获(转载)
Silverlight 4 Validation验证实例系列 Silverlight实例教程 - Validation数据验证开篇 Silverlight实例教程 - Validation数据验证基础 ...
- 2B01-View-Switcher
Gallery和swithcer联合使用 /* * Copyright (C) 2007 The Android Open Source Project * * Licensed under the ...
- 【转载】Highcharts使用指南
另附几个较好的图形组件库: 基于HTML5的开源画图组件:http://www.ichartjs.com/gettingstarted/ 图表Echarts: http://echarts.baidu ...
- MVC | 微软自带的Ajax请求
@Ajax.BegForm( ) 用来生成异步表单 Home控制器 using System; using System.Collections.Generic; using System.Linq ...
- MySQL获取Schema表名和字段信息
MySQL获取Schema表名和字段信息 获取表名 select TABLE_NAME,TABLE_TYPE,ENGINE,TABLE_ROWS,TABLE_COMMENT,CREATE_TIME,U ...
- C# 子类实例化过程
刚研究了一下C#子类实例化的过程. 首先我遇到了如下一个问题: 有类A,里面写了一个有参的构造函数,并没有提供默认的无参构造函数.现在类B继承了类A,没有写任何的构造函数. 这时如果想实例化类B就会产 ...