【问题标题】:Silverlight & C# - Open a childwindow only if a time frame passesSilverlight & C# - 仅在时间框架过去时打开子窗口
【发布时间】:2011-01-11 14:07:28
【问题描述】:

希望标题有意义,但我会描述我的问题。当 UI 执行某些工作时,我在 Silverlight 中使用子窗口来显示处理消息和旋转图像。一旦调用了 Completed Event,窗口就会关闭。

问题是当 UI 执行快速任务时,它看起来确实有点难看,因为子窗口打开然后在 1 秒内关闭。

我想要做的是仅在处理 2 秒后才打开子窗口,然后在完成时关闭。

我添加了我的 xaml 的一部分,我在下面调用孩子。我已经搜索过,但在这方面找不到任何东西,而且可能是不可能的。

void edit_Closed(object sender, EventArgs e) { EditChannelDetails edit = 作为 EditChannelDetails 的发件人;

        if (edit.DialogResult == true)
        {
            if (edit != null)
            {
                Channel edited = new Channel();
                edited.channelId = Int32.Parse(edit.ChannelID.Text);
                edited.name = edit.ChannelName.Text;
                edited.description = edit.ChannelDescription.Text;

                ChannelClient proxy = new ChannelClient(new BasicHttpBinding(), new EndpointAddress("http://servername"));
                proxy.UpdateChannelCompleted += new EventHandler<UpdateChannelCompletedEventArgs>(proxy_UpdateChannelCompleted);
                proxy.UpdateChannelAsync(edited);
            }
        }
        processingDialog.Show();
    }

    void proxy_UpdateChannelCompleted(object sender, UpdateChannelCompletedEventArgs e)
    {
        processingDialog.Close();

等等……

【问题讨论】:

    标签: silverlight childwindow


    【解决方案1】:
    Boolean closeFlag = false;
    

    启动计时器:

    DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(2) };
    
    timer.Tick += (tts, tte) => {
        timer.Stop();
        closeFlag = true;
    };
    
    timer.Start();
    

    并检查标志:

    if (!closeFlag)
    {
        processingDialog.Close();
    }
    

    【讨论】:

      猜你喜欢
      • 2014-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多