当前位置:网站首页>Createanonymousthreadx passes parameters to anonymous threads
Createanonymousthreadx passes parameters to anonymous threads
2022-06-13 04:36:00 【zxm8513】

Pass parameters to the thread
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;
// The method to be executed
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;
// The method to be executed 2
procedure MyMethod2(paramStr: string);
begin
ShowMessage(paramStr);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
paramStr: string;
begin
// demonstration 1: Parameters of the incoming
TThread.CreateAnonymousThreadX<Integer>(MyMethod, 5000).Start;
// demonstration 2:JSON Format parameters , This allows multiple parameters to be passed in at once
paramStr := '{"paramA":"1","paramB":"2"}';
TThread.CreateAnonymousThreadX<string>(MyMethod2, paramStr).Start;
end;
end.边栏推荐
- Returns the width and height of an element
- EMC整改纲要
- Solve the problem of running server nodemon reporting errors
- Basic syntax example for go
- 【Try to Hack】upload-labs通关(暂时写到12关)
- Go scheduled task cron package usage
- H5 the blue background color appears when clicking the picture
- 【剑指Offer】面试题24.反转链表
- VGA display based on de2-115 platform
- Vercel 使用 HTTP 缓存
猜你喜欢

Simple static web page + animation (small case)

一款開源的Markdown轉富文本編輯器的實現原理剖析

Express scaffold creation

VGA display based on de2-115 platform

【Flutter 问题系列第 67 篇】在 Flutter 中使用 Get 插件在 Dialog 弹窗中不能二次跳转路由问题的解决方案

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

Small program input element moving up

CTFSHOW SQL注入篇(231-253)

剑指 Offer 56 - I. 数组中数字出现的次数

ACM ICPC
随机推荐
MySQL index
2022氯化工艺操作证考试题库及模拟考试
Dagger2学习之Module的应用(二)
第三方评论插件
Go/golang connection to database
Common ways to traverse map sets
2022 ICLR | CONTRASTIVE LEARNING OF IMAGE- AND STRUCTURE BASED REPRESENTATIONS IN DRUG DISCOVERY
[sword finger offer] interview question 25 Merge two ordered linked lists
Notes on uni app
Mysql database installation
基于DE2-115平台的VGA显示
Tita performance treasure: remote one-on-one discussion
你的一对一会议效率低下,你可以这么做!
Online audio adjustment technology summary
剑指 Offer 11. 旋转数组的最小数字-二分查找
一款开源的Markdown转富文本编辑器的实现原理剖析
A simple understanding of consistent hash
工业互联网通用通信协议
CTFSHOW SQL注入篇(211-230)
一款開源的Markdown轉富文本編輯器的實現原理剖析