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线程的初级应用的更多相关文章

  1. TMsgThread, TCommThread -- 在delphi线程中实现消息循环

    http://delphi.cjcsoft.net//viewthread.php?tid=635 在delphi线程中实现消息循环 在delphi线程中实现消息循环 Delphi的TThread类使 ...

  2. TMsgThread, TCommThread -- 在delphi线程中实现消息循环(105篇博客,好多研究消息的文章)

    在delphi线程中实现消息循环 在delphi线程中实现消息循环 Delphi的TThread类使用很方便,但是有时候我们需要在线程类中使用消息循环,delphi没有提供.   花了两天的事件研究了 ...

  3. delphi 线程教学第六节:TList与泛型

    第六节: TList 与泛型   TList 是一个重要的容器,用途广泛,配合泛型,更是如虎添翼. 我们先来改进一下带泛型的 TList 基类,以便以后使用. 本例源码下载(delphi XE8版本) ...

  4. Delphi线程定时器TThreadedTimer及用法--还有TThreadList用法可以locklist

    Delphi线程定时器 - -人生如歌- - 博客园http://www.cnblogs.com/zhengwei0113/p/4192010.html (* 自己编写的线程计时器,没有采用消息机制, ...

  5. delphi 线程教学第二节:在线程时空中操作界面(UI)

    第二节:在线程时空中操作界面(UI)   1.为什么要用 TThread ?   TThread 基于操作系统的线程函数封装,隐藏了诸多繁琐的细节. 适合于大部分情况多线程任务的实现.这个理由足够了吧 ...

  6. delphi 线程教学第一节:初识多线程

    第一节:初识多线程   1.为什么要学习多线程编程?   多线程(多个线程同时运行)编程,亦可称之为异步编程. 有了多线程,主界面才不会因为耗时代码而造成“假死“状态. 有了多线程,才能使多个任务同时 ...

  7. 多线程的基本概念和Delphi线程对象Tthread介绍

    多线程的基本概念和Delphi线程对象Tthread介绍 作者:xiaoru    WIN 98/NT/2000/XP是个多任务操作系统,也就是:一个进程可以划分为多个线程,每个线程轮流占用CPU运行 ...

  8. Delphi线程的终止

    当线程对象的Execute()执行完毕,我们就认为此线程终止了.这时候,它会调用Delphi的一个标准例程EndThread(),这个例程再调用API函数ExitThread().由ExitThrea ...

  9. Delphi线程基础知识

    参考http://blog.chinaunix.net/uid-10535208-id-2949323.html 一.概述 Delphi提供了好几种对象以方便进行多线程编程.多线程应用程序有以下几方面 ...

随机推荐

  1. SkipList的实现

    当做笔记记录下来:) 相比于bTree,skiplist占用更多的空间. 而在并发的环境下skiplist会比bTree效率更高. (bTree插入的时候需要rebalance,需要lock比较多的结 ...

  2. windows系统下GCC的安装与配置

    刚开始看 C++ Primer,看到编译器的部分,自己搜了搜怎么搭建GCC,搜到以下内容,复制过来留个印象: windows系统下GCC的安装方法,以及一些环境变量的配置,如果对GCC不是很清楚,关于 ...

  3. c#上一周下一周代码

    public partial class Form1 : Form { DateTime dtNow; public Form1() { InitializeComponent(); } privat ...

  4. C语言学习笔记(二) 基础知识

    数据类型 C语言数据可以分为两大类: 基本类型数据和复合类型数据: 基本类型数据 整数 整型   (int)  ——占4字节 短整型(short int)  ——占2字节    长整型(long in ...

  5. 转:Window10下RabbitMQ安装图文教程

    一.erlang下载安装 1.下载 下载erlang,原因在于RabbitMQ服务端代码是使用并发式语言erlang编写的,下载地址:http://www.erlang.org/downloads,双 ...

  6. Angularjs学习笔记1_基本技巧

    10.AngularJS ng-click   <button ng-click="clickCounter = clickCounter + 1">Click Me! ...

  7. C++语言基础(3)-类和对象

    类是创建对象的模板,一个类可以创建多个对象,每个对象都是类类型的一个变量:创建对象的过程也叫类的实例化.每个对象都是类的一个具体实例(Instance),拥有类的成员变量和成员函数. 一.类的定义 一 ...

  8. docker的使用01

    使用Dockerfile构建镜像 vim dockerfile01 #注释信息 FROM ubuntu:latest //导入镜像 MAINTAINER leo "leo@leo.com&q ...

  9. hMailServer 附件大小限制

    修改php.ini文件 1.post_max_size = 10M 表单提交最大数据为10M.此项不是限制上传单个文件的大小,而是针对整个表单的提交数据进行限制的. 2.file_uploads = ...

  10. 随机生成数,摘自算法竞赛入门经典P120-P123测试STL。

    //#include<bits/stdc++.h> #include<cstring> #include<iostream> #include<cstdio& ...