1.使用

procedure Parallel.Async(task: TProc; taskConfig: IOmniTaskConfig);

匿名委托访问网站

program main;

{$APPTYPE CONSOLE}

{$R *.res}

uses
System.SysUtils,
OtlParallel, OtlTask,
IdHttp,
Web.HTTPApp,
System.classes, WinApi.Windows; procedure HttpGet(Host, URL: String);
var
http: TIdHttp;
begin
http := TIdHttp.Create; // http.Request.Host := Host;
http.Request.Method := 'GET';
http.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36';
http.Request.AcceptLanguage :='zh-CN,zh;q=0.8';
http.Get(Host + URL); Writeln('===================Response Header==========================');
Writeln('Server: ' + http.Response.Server);
Writeln('Status Code :' + http.Response.ResponseCode.ToString);
Writeln('CharSet:' + http.Response.CharSet);
Writeln('ContentLength:' + http.Response.ContentLength.ToString());
Writeln('ContentType:' + http.Response.ContentType);
http.Free;
end;
begin
Parallel.Async(
procedure(const task: IOmniTask)
begin Writeln('Thread ID ' + GetCurrentThreadID.ToString());
HttpGet('http://zh.wikipedia.org/', String(HttpEncode('wiki/文档')));
//访问主界面资源使用Invoke Invoke主线程运行, 访问GUI
// task.Invoke();
end
); Parallel.Async(
procedure(const task: IOmniTask)
begin
Writeln('Thread ID ' + GetCurrentThreadID.ToString());
HttpGet('http://zh.wikipedia.org/', String(HttpEncode('wiki/文档')));
//访问主界面资源使用Invoke
// task.Invoke();
end
); Parallel.Async(
procedure(const task: IOmniTask)
begin
Writeln('Thread ID ' + GetCurrentThreadID.ToString());
HttpGet('http://zh.wikipedia.org/', String(HttpEncode('wiki/文档')));
//访问主界面资源使用Invoke
// task.Invoke();
end
);
writeln('异步执行');
Readln;
end.

Omnithreadlibary学习(2)-IOmniTask异步执行的更多相关文章

  1. Omnithreadlibary学习(3)-IOmniTask异步执行SendMessage

    在任务中发送消息, 可以是函数或者对象方法 TOmniTaskMessageEvent = procedure(const task: IOmniTaskControl; const msg: TOm ...

  2. Python学习---Python的异步IO[all]

    1.1.1. 前期环境准备和基础知识 安装: pip3 install aiohttp pip3 install grequests pip3 install wheel pip3 install s ...

  3. How to make asynchronous HTTP requests in PHP 4种PHP异步执行的常用方式

    [是否等待返回就执行下一步] How to make asynchronous HTTP requests in PHP - Stack Overflow https://stackoverflow. ...

  4. ASP.NET MVC 学习笔记-7.自定义配置信息 ASP.NET MVC 学习笔记-6.异步控制器 ASP.NET MVC 学习笔记-5.Controller与View的数据传递 ASP.NET MVC 学习笔记-4.ASP.NET MVC中Ajax的应用 ASP.NET MVC 学习笔记-3.面向对象设计原则

    ASP.NET MVC 学习笔记-7.自定义配置信息   ASP.NET程序中的web.config文件中,在appSettings这个配置节中能够保存一些配置,比如, 1 <appSettin ...

  5. Netty推荐addListener回调异步执行

    说明 Netty推荐使用addListener的方式来回调异步执行的结果,这种方式优于Future.get,能够更精确地把握异步执行结束的时间. 错误理解使用addListener的方式 代码如下: ...

  6. Promise then中回调为什么是异步执行?Promise执行机制问题

    今天发现一个问题,看下方代码 let p = new Promise(function(resolve, reject) { resolve() console.log('); }); p.then( ...

  7. Linux下搭建实现HttpRunnerManager的异步执行、定时任务及任务监控

    前言 在之前搭建的HttpRunnerManager接口测试平台,我们还有一些功能没有实现,比如异步执行.定时任务.任务监控等,要完成异步执行,需要搭建 RabbitMQ 等环境,今天我们就来实现这些 ...

  8. [源码解析] PyTorch 分布式(16) --- 使用异步执行实现批处理 RPC

    [源码解析] PyTorch 分布式(16) --- 使用异步执行实现批处理 RPC 目录 [源码解析] PyTorch 分布式(16) --- 使用异步执行实现批处理 RPC 0x00 摘要 0x0 ...

  9. Python开发程序:RPC异步执行命令(RabbitMQ双向通信)

    RPC异步执行命令 需求: 利用RibbitMQ进行数据交互 可以对多台服务器进行操作 执行命令后不等待命令的执行结果,而是直接让输入下一条命令,结果出来后自动打印 实现异步操作 不懂rpc的请移步h ...

随机推荐

  1. 【转】ST05

    一. SQL Trace 通过SQL跟踪,可以具体查询数据来源于哪些数据库表, 例如:可以查询某个交易(或几个交易)所涉及的数据库表. 为了减少在最终查询结果的工作量,要在屏幕显示你所要显示的数据的前 ...

  2. Java - 错误: &quot;java.lang.ArrayIndexOutOfBoundsException: length=1; index=1&quot;

    错误: "java.lang.ArrayIndexOutOfBoundsException: length=1; index=1" 本文地址: http://blog.csdn.n ...

  3. TransactionScope

    最近发现微软自带的TransactionScope(.Net Framework 2之后)是个好东东,提供的功能也很强大. 首先说说TransactionScope是什么,并能为我们做什么事情.其实看 ...

  4. RedHat Enterprise Linux 6.4使用Centos 6 的yum源 分类: 服务器搭建 Nginx 2015-07-14 14:11 5人阅读 评论(0) 收藏

    转载自:http://blog.sina.com.cn/s/blog_50f908410101cto6.html 思路:卸载redhat自带yum,然后下载centos的yum,安装后修改配置文件 1 ...

  5. [React Native] Passing data when changing routes

    The way you make HTTP requests in React Native is with the Fetch API. In this video we'll talk about ...

  6. [Javascript] The Array filter method

    One very common operation in programming is to iterate through an Array's contents, apply a test fun ...

  7. 前端JS开发框架-DHTMLX--dhtmlXTree

    介绍 dhtmlxTree是一个功能丰富的JavaScript树菜单  它允许您快速添加一个好看的,基于ajax的web页面的分层树. treeview支持在线节点编辑.先进的拖放,三态复选框等等.由 ...

  8. find which process occupy the PORT

    mac :   lsof -i:8080 linux : netstat -anltp | grep 8080

  9. 通过虚拟机VMware来练习安装ESXi

    关于VMware vSphere组件ESXi,大家请自行百度.大概的意思我简单的先理解为这个组件是通过在服务器上安装上ESXi系统,继而虚拟化整个服务器的硬件资源为之后虚拟各种客户端所用.相比较大家较 ...

  10. JUnit4简要说明

    单元测试(unit testing),是指对软件中的最小可测试单元进行检查和验证. 开发者编写一小段代码,用于检验被测代码的一个很小的.很明确的功能是否正确. 通常而言,一个单元测试是用于判断某个特定 ...