应用程序在前台崩溃时崩溃

时间:2023-01-22 15:42:13

In my project I need to call many web service on a screen. It works fine. I am calling services and make them to sit into database respectively. And same working in background.

在我的项目中,我需要在屏幕上调用许多Web服务。它工作正常。我正在调用服务并让它们分别进入数据库。同样在后台工作。

But the app crashes when we press Home button and come back to app. Means when app turns into foreground, progress bar is hanging untill data insert into database and again progress hud is working. So
I want progress hud should work even data is inserting or web service is getting called and my app should not crash even it comes to foreground.

但是,当我们按下主页按钮并返回应用程序时,应用程序崩溃了。表示当app变成前台时,进度条挂起,直到数据插入到数据库中并再次进行hud工作。所以我想进步hud应该工作,即使数据插入或Web服务被调用,我的应用程序不应该崩溃,即使它来到前台。

Is there any way to get rid out of this?

有没有办法摆脱这个?

1 个解决方案

#1


0  

You will have to call your webservice in background queue and hide progress hud in main queue.

您必须在后台队列中调用Web服务并在主队列中隐藏进度hud。

dispatch_async(
  dispatch_get_global_queue(
     DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  //webservice operations`
    dispatch_async(dispatch_get_main_queue(), ^(){`
    //hide hud

    });});

#1


0  

You will have to call your webservice in background queue and hide progress hud in main queue.

您必须在后台队列中调用Web服务并在主队列中隐藏进度hud。

dispatch_async(
  dispatch_get_global_queue(
     DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  //webservice operations`
    dispatch_async(dispatch_get_main_queue(), ^(){`
    //hide hud

    });});