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. Objective-C(十七、KVC键值编码及实例说明)——iOS开发基础

    结合之前的学习笔记以及參考<Objective-C编程全解(第三版)>,对Objective-C知识点进行梳理总结.知识点一直在变,仅仅是作为參考,以苹果官方文档为准~ 十七.键值编码 K ...

  2. lua类库 middleclass学习笔记

    middleclass使在lua中面象对象变的简单 抄了一遍他的示例代码运行着试了试,基本懂了 local class = require 'middleclass' --类的继承 Person = ...

  3. ios 中尝试多次请求

    -(void)tryRun { tryTimes++; id obj = [ASODataManager getAppleAccount]; if (obj) { __block FirstViewC ...

  4. where 泛型类型参数及约束

    private void InsertData<TRowMetadata, TFieldMetadata, TCellMetadata>(IMetadataReader<TRowMe ...

  5. php的pear包管理

    1.安装:  $ sudo wget http://pear.php.net/go-pear.phar  $ sudo php go-pear.har 2.查看pear下安装的包:  $ pear l ...

  6. oracle10g安装,卸载

    一.安装 1.因为oracle的特殊性,笔者选择通过虚拟机安装windows7旗舰版安装数据库,大家的系统假设是windows xp.windows 7,windows 8能够直接安装,windows ...

  7. C++语言基础(15)-友元函数和友元类

    一个类中可以有 public.protected.private 三种属性的成员,通过对象可以访问 public 成员,只有本类中的函数可以访问本类的 private 成员.现在,我们来介绍一种例外情 ...

  8. poj 3666 河南省第七届程序设计D题(山区修路)

    题目大意: 给定一个序列,以最小代价将其变成单调不增或单调不减序列,求最小的变动价值:需要用到离散化dp 状态转移方程: dp[i][j]=abs(j-w[i])+min(dp[i-1][k]);(k ...

  9. Help Hanzo lightof 1197 求一段区间内素数个数,[l,r] 在 [1,1e9] 范围内。r-l<=1e5; 采用和平常筛素数的方法。平移区间即可。

    /** 题目:Help Hanzo lightof 1197 链接:https://vjudge.net/contest/154246#problem/M 题意:求一段区间内素数个数,[l,r] 在 ...

  10. java 定时器

    import java.io.IOException; import java.util.Timer; public class TimerTest { public static void main ...