none
多线程显示动画 RRS feed

  • 问题

  • 我做了一个 动画,在进程开始的时候启动,在进程结束的时候停止,开始的时候显示正确,当在timer里面停止的时候 anmi->Stop()时不执行也不出错,如何停止动画? 代码如下:

    bool MainPage::GetData(){

          if (CoreApplication::Properties->HasKey("WaitAnim")){
              auto wa = safe_cast<Windows::UI::Xaml::Media::Animation::Storyboard^>(CoreApplication::Properties->Lookup("WaitAnim"));
              wa->Begin();
          }
          auto timerDelegate = [this](Windows::System::Threading::ThreadPoolTimer^ timer)
          {
                 auto uiDelegate = [this]()
                 {
                   ...
                 };
                  Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal, ref new Windows::UI::Core::DispatchedHandler(uiDelegate));
                   if (CoreApplication::Properties->HasKey("NotifyEnd"))
                   {
                          timer->Cancel();
                          if (CoreApplication::Properties->HasKey("WaitAnim"))
                          {
                                 auto anim = safe_cast<Windows::UI::Xaml::Media::Animation::Storyboard^>(CoreApplication::Properties->Lookup("WaitAnim"));
                                  anim->Stop();
                           }
                    }
           };
           DecoderData();
    }




    2014年6月29日 8:07

答案

  • 你好 gray_cat,

    你能把wa这个StoryBoard传进来,然后wa->Stop()么?

    一般都是给Storyboard命名,比如说名字叫storyboard,那么开始的话就直接storyboard->Begin()不需要再lookup了。

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    2014年7月2日 7:38
    版主