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. lua面向对象编程 《lua程序设计》 16章 笔记

    Lua中的table就是一种对象,即它拥有状态.拥有独立于其值的标识(self).table与对象一样具有独立于创建者和创建地的征集周期 什么叫对象拥有独立的生命周期? Account = {bala ...

  2. VB的第一个项目

     前言-----本人也是刚刚接触VB,企业的VB代码基本能看的懂,但是自己开发,只能呵呵.一般在刚学习一门新的语言时,很容易发生一些自己相当然的认识错误,so,记下并分享开发学习的过程,望指正.--- ...

  3. ASP.NET MVC Razor 输出没有编码的HTML字符串

    Razor引擎之前要输出一段没有编码的字符串,只要@加变量名就可以了,Razor却不能这样,感觉是有点麻烦. 在Razor Beta 2以前的版本可以: @(new HtmlString(mystri ...

  4. Atitit. C#.net clr 2.0  4.0新特性

    Atitit. C#.net clr 2.0  4.0新特性 1. CLR内部结构1 2. CLR 版本发展史3 3. CLR 2.0 3 4. CLR 4 新特性 概览4 4.1.1.  托管与本地 ...

  5. 【转载】Highcharts使用指南

    另附几个较好的图形组件库: 基于HTML5的开源画图组件:http://www.ichartjs.com/gettingstarted/ 图表Echarts: http://echarts.baidu ...

  6. 转载-android studio 各种问题

    android studio 各种问题 1.dexDebug ExecException finished with non-zero exit value 2 全bug日志如下: (Error:Ex ...

  7. centos 启动 nginx

    service nginx start https://jingyan.baidu.com/article/bad08e1ec2adc709c85121aa.html

  8. A - Bi-shoe and Phi-shoe 欧拉函数

    /** 题目:A - Bi-shoe and Phi-shoe 链接:https://vjudge.net/contest/154246#problem/A 题意:每一个数都有一个得分,它的得分就是, ...

  9. php文件加密

    1.在线加密 网址:http://www.phpjm.net/encode.html 本人测试过还可以,就是纯加密,没有解密.

  10. setTimeout里无法调用鼠标事件的event

    问题的由来是下面这段代码: middleOnmouseLeave: function (event) { setTimeout(function () { event.currentTarget.st ...