LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Picture ring animation freezes (LabWindows)

Solved!
Go to solution

Hi all,

 

I want to display a wait panel with an animation in it when my app is processing data, using the animation control. The problem is that the animation freezes because all the resources are in the data processing (when it's no data processing, the animation works correctly).

 

I tried to create a thread for running the wait panel on it, but it continues freezing because there's a loop waiting for when data processing is finished. I created another thread for that loop, and now the animation works, but only if there's events over the waiting panel (moving the mouse over it or something).

 

I know this is not very efficient. Maybe someone knows an easy way to do this.

Thank you!! 

 

 

My code is this: 

 

int Calculate (...)
{

        ShowWaitPanel();

       //DATA PROCESSING...
        HideWaitPanel();          

}

void ShowWaitPanel(void)
{         
    waitPanelActive=1; 
    CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE,WaitThreadFunction,
        NULL,&waitThreadFunctionId);
}

void HideWaitPanel(void)
{  
     waitPanelActive=0; 
    CmtWaitForThreadPoolFunctionCompletion (DEFAULT_THREAD_POOL_HANDLE,

                 waitThreadFunctionId,OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
    CmtReleaseThreadPoolFunctionID (DEFAULT_THREAD_POOL_HANDLE, waitThreadFunctionId);      
}

static int CVICALLBACK WaitThreadFunction (void *functionData)
{      
    waitPanelHandle = LoadPanel (0, "SpectrumAnalyzer.uir", WAITPANEL); 
     DisplayPanel (waitPanelHandle);     
    AnimateCtrl_ConvertFromPictRing (waitPanelHandle,  WAITPANEL_PICTURERING);
    AnimateCtrl_SetAttribute (waitPanelHandle, WAITPANEL_PICTURERING, ATTR_ANIMATE_ENABLED, 1);
    AnimateCtrl_SetAttribute (waitPanelHandle, WAITPANEL_PICTURERING, ATTR_ANIMATE_FRAME_INTERVAL, 0.1);
    AnimateCtrl_SetAttribute (waitPanelHandle, WAITPANEL_PICTURERING, ATTR_ANIMATE_STOP_ON_LAST_FRAME, 0);

 

    CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE,CheckWaitPanelFlagThread,NULL,&checkWaitFlagThreadId);
    CmtWaitForThreadPoolFunctionCompletion (DEFAULT_THREAD_POOL_HANDLE,checkWaitFlagThreadId,

                OPT_TP_PROCESS_EVENTS_WHILE_WAITING);
    CmtReleaseThreadPoolFunctionID (DEFAULT_THREAD_POOL_HANDLE, checkWaitFlagThreadId);     

    DiscardPanel (waitPanelHandle);
    return 0;
}

 

static int CVICALLBACK CheckWaitPanelFlagThread (void *functionData)
{
    while(waitPanelActive)

    {  

    }
    return 0;          
}
0 Kudos
Message 1 of 4
(3,535 Views)
Any suggestions?
0 Kudos
Message 2 of 4
(3,490 Views)
Solution
Accepted by topic author Tamargo

You need to process events. The second scheduled thread function is not necessary. Try this:

 

static int CVICALLBACK WaitThreadFunction (void *functionData)
{      
    waitPanelHandle = LoadPanel (0, "SpectrumAnalyzer.uir", WAITPANEL); 
     DisplayPanel (waitPanelHandle);     
    AnimateCtrl_ConvertFromPictRing (waitPanelHandle,  WAITPANEL_PICTURERING);
    AnimateCtrl_SetAttribute (waitPanelHandle, WAITPANEL_PICTURERING, ATTR_ANIMATE_ENABLED, 1);
    AnimateCtrl_SetAttribute (waitPanelHandle, WAITPANEL_PICTURERING, ATTR_ANIMATE_FRAME_INTERVAL, 0.1);
    AnimateCtrl_SetAttribute (waitPanelHandle, WAITPANEL_PICTURERING, ATTR_ANIMATE_STOP_ON_LAST_FRAME, 0);

 

    while(waitPanelActive)

    {

        ProcessSystemEvents();  

    }

    DiscardPanel (waitPanelHandle);


    return 0;          
}

 

Mert A.

National Instruments

Message 3 of 4
(3,486 Views)

It works perfectly.

 

Thank you very much!!

 

 

Eduardo - Spain 

0 Kudos
Message 4 of 4
(3,484 Views)