当前位置:网站首页>CreateAnonymousThreadX给匿名线程传递参数
CreateAnonymousThreadX给匿名线程传递参数
2022-06-13 04:29:00 【zxm8513】

给线程传递参数
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses TAnonymousThreadXUnit;
// 要执行的方法
procedure MyMethod(count: Integer);
var
i: Integer;
begin
for i := 0 to count do
begin
Form1.Canvas.Lock;
Form1.Canvas.TextOut(10, 10, IntToStr(i));
Form1.Canvas.Unlock;
end;
end;
// 要执行的方法2
procedure MyMethod2(paramStr: string);
begin
ShowMessage(paramStr);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
paramStr: string;
begin
// 演示1:参数传入
TThread.CreateAnonymousThreadX<Integer>(MyMethod, 5000).Start;
// 演示2:JSON格式参数,这样允许一次传入多个参数
paramStr := '{"paramA":"1","paramB":"2"}';
TThread.CreateAnonymousThreadX<string>(MyMethod2, paramStr).Start;
end;
end.边栏推荐
- 【剑指Offer】面试题25.合并两个有序的链表
- Redis data persistence
- 2022 ICLR | CONTRASTIVE LEARNING OF IMAGE- AND STRUCTURE BASED REPRESENTATIONS IN DRUG DISCOVERY
- web自动化测试之webdriver api总结
- Answer private message @ Tiantian Wx //2022-6-12 C language 51 single chip microcomputer led analog traffic light
- Differences and relations between three-tier architecture and MVC
- Summary of webdriver API for web automated testing
- Catalan number
- 一款開源的Markdown轉富文本編輯器的實現原理剖析
- dumi 搭建文档型博客
猜你喜欢

The could not find com scwang. smart:refresh-layout-kernel:2.0.3. Required by: project: the app cannot load the third-party package

Tree array explanation

Hugo blog building tutorial

EMC rectification outline

2022 ICML | Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets

A simple understanding of consistent hash

Hugo 博客搭建教程

Redis data persistence

10 minutes to thoroughly understand how to configure sub domain names to deploy multiple projects

力扣刷题647.回文子串
随机推荐
2019 Blue Bridge Cup
ACM ICPC
力扣刷题647.回文子串
Redis
PHP security development 15 user password modification module
UE4 learning notes - functions of terrain tool
This Sedata uses multiple methods to dynamically modify objects and values in arrays. Object calculation properties
MySQL索引
2022 ICML | Pocket2Mol: Efficient Molecular Sampling Based on 3D Protein Pockets
Ionic Cordova command line
SS selector
CTFSHOW 常用姿势篇(821-830)
Hugo blog building tutorial
Koa file upload and download
It's the Caesar code. (*‘▽‘*)*
String full summary
Tree array explanation
Application of dagger2 learning module (II)
建模杂谈系列143 数据处理、分析与决策系统开发的梳理
Analyse du principe de mise en œuvre d'un éditeur de texte open source markdown - to - rich