在iOS中创建一个异步串行队列

3
我需要创建一个异步执行的队列,但任务执行的顺序必须是串行的。
dispatch_queue_t queue;
queue = dispatch_queue_create("com.test.app", NULL); //create a serial queue can either be null or DISPATCH_QUEUE_SERIAL

dispatch_async(queue,
                ^{

                //Mycode for doing background http

                }

1
你的问题确切是什么? - Marcel
1个回答

5
我认为你正在正确地执行这个操作。
dispatch_queue_t queue;
queue = dispatch_queue_create("com.test.app", NULL); //create a serial queue can either be null or DISPATCH_QUEUE_SERIAL

dispatch_async(queue,
                ^{
task1;
task2;
...

all this tasks wil be done done sequentially 


                }

如果在同一顺序中创建另一个新队列,它会是顺序的吗? - raghul

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接