银光与C# - 仅当时间范围过去时才打开子窗口

发布于 2024-10-11 07:12:31 字数 1251 浏览 3 评论 0原文

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

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

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

我添加了 xaml 的一部分,我在其中调用下面的子项。我已经搜索过,但找不到任何关于此的信息,这可能是不可能的。

void edit_Closed(对象发送者,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();

ETC.....

Hopefully the title makes sense but I will discribe my issue. I am using a childwindow in Silverlight to display a Processing message and rotating image when the UI is doing some work. Once a Completed Event is called, the window then closes.

Problem is that it does look a little ugly when the UI performs a quick task as the child window opens and then closes in under 1 second.

What I want to be able to do is have the child window open only if 2 seconds of processing has passed and then close on complete.

I have added a section of my xaml where I am calling the child below. I have searched but cannot find anything on this and it might not be possible.

void edit_Closed(object sender, EventArgs e)
{
EditChannelDetails edit = sender as 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();

Etc.....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

奢望 2024-10-18 07:12:31
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();
}
Boolean closeFlag = false;

Start a timer:

DispatcherTimer timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(2) };

timer.Tick += (tts, tte) => {
    timer.Stop();
    closeFlag = true;
};

timer.Start();

And check flag:

if (!closeFlag)
{
    processingDialog.Close();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文