block

WPF asynchronous Task<T> blocking UI

青春壹個敷衍的年華 提交于 2019-12-05 10:50:31
I already worked with Task type. And all was good while Task return nothing. For example: XAML: <Button Name="_button" Click="ButtonBase_OnClick"> Click </Button> CodeBehind: private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { _button.IsEnabled = false; Task.Factory.StartNew(() => { Thread.Sleep(5*1000); Dispatcher.Invoke(new Action(() => _button.IsEnabled = true)); }); } This works fine. But I want to Task returns some value, for example Boolean . So I need to use Task<Boolean> : private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { _button.IsEnabled = false; var

[swift]-闭包前oc中block的说明

若如初见. 提交于 2019-12-05 10:47:01
1:oc中blcok是一个匿名函数,常用于回调 2:oc中blcok的三种常见定义: #import "HttpTool.h" typedef void(^myBlock)(NSString *name); @interface HttpTool () //typedef定义法 - (void)httpToolBlock:(myBlock)callBlock; // void(^block名字)(参数列表) @property (nonatomic, copy)void(^callBlock)(NSString *name); // 方法的block定义 //(void(^)(NSString *str))callBlock - (void)blockFunc:(void(^)(NSString *name))callBlock; @end 3:对于block中经常会注意循环引用的问题:最好的办法是使用weckself,常见写法: #define WS(weakSelf) __weak __typeof(&*self)weakSelf = self; 1. __weak XJViewController *weakSelf = self; 2. __weak typeof(self) weakSelf = self; 3. __weak __typeof(self)weakSelf

stub method with block of code as parameter with OCMock

狂风中的少年 提交于 2019-12-05 10:36:10
Is there a way to stub method, that takes block as it's parameter? For example mehod: - (void)reverseGeocodeLocation:(CLLocation *)location completionHandler:(CLGeocodeCompletionHandler)completionHandler; Yes. The easiest way would be to accept anything: id mockGeocoder = [OCMockObject mockForClass:[CLGeocoder class]]; [[mockGeocoder stub] reverseGeocodeLocation:[OCMOCK_ANY] completionHandler:[OCMOCK_ANY]]; It gets a bit trickier if you want to verify a particular block is passed in. One option is to make your completion handler a property of your class, initialize it when you initialize your

Linux文件和目录的属性及权限

一笑奈何 提交于 2019-12-05 09:43:00
1.Linux中的文件 1.1 文件属性概述 Linux系统中的文件或目录的属性主要包括: 索引节点inode 文件类型 权限属性 链接数 所归属的用户和用户组 最近修改时间 等内容: 下面我们看执行 ls -lih 命令的结果(共10列): -l 长格式 -i 显示 索引节点 inode -h 以人类熟悉的方式显示文件大小 [root@oldboy oldboy]# ls -lhi total 32K 275427 -rw-r--r-- 1 root root 8 Sep 4 14:56 123.log 275423 -rw-r--r-- 1 root root 0 Sep 4 14:46 dd.tx 275576 drwxr-xr-x 3 root root 4.0K Oct 1 2019 ext 275695 -rw-r--r-- 1 root root 71 Sep 4 19:45 file.txt 275582 -rw-r--r-- 1 root root 0 Oct 1 2019 jeacen 275694 -rw-r--r-- 1 root root 101 Sep 4 18:30 nginx.conf 275583 -rw-r--r-- 1 root root 0 Oct 1 2019 oldboy 275424 -rw-r--r-- 1 root root 0

图像增强

假装没事ソ 提交于 2019-12-05 09:07:54
1 Mat ImageAHE(Mat img, int block) 2 { 3 Mat AHE_GO = img.clone(); 4 5 int width = img.cols; 6 int height = img.rows; 7 int width_block = width / block; //每个小格子的长和宽 8 int height_block = height / block; 9 //存储各个直方图 10 11 12 int tmp2[16 * 16][256] = { 0 };//10要和block保持一致 13 float C2[16 * 16][256] = { 0.0 }; 14 //分块 15 int total = width_block * height_block;//分割的总的块儿数 16 for (int i = 0; i < block; i++) 17 { 18 for (int j = 0; j < block; j++) 19 { 20 int start_x = i * width_block; 21 int end_x = start_x + width_block; 22 int start_y = j * height_block; 23 int end_y = start_y + height_block; 24 25

Rails' concat method and blocks with do…end doesn't work

霸气de小男生 提交于 2019-12-05 08:58:21
I just read about Rails' concat method to clean up helpers that output something here http://thepugautomatic.com/2013/06/helpers/ . I played around with it, and I have found out, that it doesn't react the same way to blocks with curly braces and to blocks with do...end. def output_something concat content_tag :strong { "hello" } # works concat content_tag :strong do "hello" end # doesn't work concat(content_tag :strong do "hello" end) # works, but doesn't make much sense to use with multi line blocks end I didn't know that curly braces and do...end blocks seem to have different meanings. Is

How is the value of a begin block determined?

微笑、不失礼 提交于 2019-12-05 08:37:57
According to The Ruby Programming Language p.164. If a begin statement doesn't propagate an exception, then the value of the statement is the value of the last expression evaluated in the begin , rescue or else clauses. But I found this behavior consistent with the begin block together with else clause and ensure clause . Here is the example code: def fact (n) raise "bad argument" if n.to_i < 1 end value = begin fact (1) rescue RuntimeError => e p e.message else p "I am in the else statement" ensure p "I will be always executed" p "The END of begin block" end p value The output is: "I am in

Blocks and retain cycles

佐手、 提交于 2019-12-05 08:14:37
One minor question: why is Xcode complaining that listing 1 would lead to a retain cycle, while in listing 2 it does not? In both cases _clients is an int instance variable. In listing 2 it is assigned 0 in the init method. Background info: I would like to execute the loop in the block, as long as at least one client is requesting updates from the iPhone accelerometer, which I am publishing to a redis channel. If there are no more clients left, the loop would quit and stop publishing accelerometer data. Listing 2 comes from a small test app I wrote to verify that my idea works. Listing 1 is

Add custom header for Checkout pages in Magento (1.8.x)

混江龙づ霸主 提交于 2019-12-05 08:02:37
问题 I am trying to add a customised header to my Checkout pages, I have figured out removing the header from the page is basically adding a node in the /layout/checkout.xml file, could anyone explain how to basically a new altered header that only applies to all the Checkout pages. Current default/layout/checkout.xml <default> <remove name="footer"> <!-- removes the footer from checkout --> ... // all other xml data.. </default> pseudocode for my theme if (a CHECKOUT PAGE) { use 'custom checkout

代码审计-禅道9.2.1-sql注入

坚强是说给别人听的谎言 提交于 2019-12-05 07:23:05
0x00 前言 审计cms: 禅道开源项目管理软件 版本:9.2.1 工具:phpstorm+xdebug+seay 网站地址:http://localhost/CodeReview/ZenTaoPMS.9.2.1/www/ 严重参考: https://www.cnblogs.com/iamstudy/articles/chandao_pentest_1.html https://www.anquanke.com/post/id/160473 0x01 路由 审计cms,首先要研究cms的路由,关注网站根目录下的 .htaccess文件 。该文件出现: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule (.*)$ index.php/$1 [L] </IfModule> 所有url,除了文件或者目录,都重写到index.php下。既该cms的入口文件是index.php。 查看 index.php 文件。 加载框架类: include '../framework/router.class.php'; include '../framework/control.class.php';