• 中文版
  • Download wpfTest - 319.26 KB(code project)

Introduction

the demo with GIF animation ,multithreading,and use httpwatch to get the url of flv file

Background

c# wpf httpwatch

Points of Interest

Did you learn anything interesting/fun/annoying while writing the code? Did you do anything particularly clever or wild or zany?

History

Keep a running update of any changes or improvements you've made here.

the demo includes:

gif animation in wpf

multithreading in wpf

use httpwatch to get the url of flv file

1.gif animation in wpf

the first problem is how to show gif aninamation in wpf ?

here I use a library called "GifImageLib". :) this is a prefect work! it works fine !

2.multithreading in wpf

the multithreading in wpf called "Dispatcher" . After I searched in msdn.I wrote the code for multithreading.

Code
 BackgroundWorker _backgroundWorker=null;
        string flvUrl = string.Empty;
        string strUrl = string.Empty;
        public Window1()
        {
            InitializeComponent();
         }

        private delegate void DoWorkDelegate(int time);
        private void btnGet_Click(object sender, RoutedEventArgs e)
        {
            /**/////first try , gif stoped
            //imageLoad.Visibility = Visibility.Visible;
            //new Thread(() =>
            //{
            //    Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
            //    {
            //        Thread.Sleep(5000);
            //        imageLoad.Visibility = Visibility.Hidden;
            //        tbWait.Visibility = Visibility.Hidden;

            //    }));
            //}).Start();
            _backgroundWorker = new BackgroundWorker();
            _backgroundWorker.DoWork+=new DoWorkEventHandler(DoWork);
            _backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(FinsihWork);
            BeforeWork();
            _backgroundWorker.RunWorkerAsync();
            _backgroundWorker.Dispose();
        }
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            //fake the process
             for (int i = 0; i < 10; i ++)
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                {
                    WorkProgress.Value = i*10;
                }));
                Thread.Sleep(100);
            }
            try
            {
                if(strUrl!=string.Empty)
                    parseUrl(strUrl);
            }
            catch
            {
                    flvUrl="error";
            }
        }
        private void BeforeWork()
        {
            imageLoad.Visibility = Visibility.Visible;
            WorkProgress.Visibility = Visibility.Visible;
            WorkProgress.Maximum = 100;
            WorkProgress.Minimum = 0;
            WorkProgress.Value = 0;
            btnGet.IsEnabled = false;
            strUrl = textBox1.Text;
        }

        private void FinsihWork(object sender,RunWorkerCompletedEventArgs e)
        {
            WorkProgress.Visibility = Visibility.Hidden;
            imageLoad.Visibility = Visibility.Hidden;
            btnGet.IsEnabled = true;
            if (flvUrl != "error")
                tbResult.Text = flvUrl;
        }

this is BackgroundWorker demo.

   _backgroundWorker.DoWork+=new DoWorkEventHandler(DoWork);

you can coding your work which needed long time.

 _backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(FinsihWork);

you can coding which you needed after the long time task.

3.use httpwatch to get the url of flv file

you can get the free httpwatch version from httpwatch.com . and you only need add com preference(httpwatch) to project

the code I using c#

Code
      private bool UrlExistsUsingHttpWebRequest(string url)
        {
            try
            {
                System.Net.WebRequest.Create(url);
                return true;
            }
            catch
            {
                return false;
            }
        }

        private void tbResult_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (flvUrl != "error") 
                System.Diagnostics.Process.Start(flvUrl);
        }

Ok,finished

中文版

转载于:https://www.cnblogs.com/conan77/archive/2009/06/13/1502656.html

wpf demo (gif , multithredading,httpwatch)相关推荐

  1. WPF数据驱动应用程序上具有通用Lambda表达式的筛选器模式

    从Github下载源代码 介绍 本文演示了在WPF上具有通用lambda表达式的筛选器模式.筛选器模式与管道一起在数据驱动的应用程序中大量使用.使用C#lambda表达式,可以缩短代码并使代码通用化. ...

  2. WPF基础(十八)C#正则表达式:匹配汉字、特殊字符、字母、数字、IP/端口号等等

    目录 第一章.简介 1.1.问题描述 1.2.System.Text.RegularExpressions.Regex.Match介绍 1.2.1.基本规则说明 1.2.2.Regex类常用的方法 1 ...

  3. EPPlus 读写 Excel 资料收集

    1. EPPlus概述 EPPlus 是使用Open Office XML格式(xlsx)读写Excel 2007 / 2010文件的.net开发库. 官网:http://epplus.codeple ...

  4. 用AnyStock和LightningChart打造炫酷的制作股票、金融业K线图工具产品

    近年来资本市场风起云涌,如何通过数字化.图形化手段分析金融产品是一个将经验工具化的手段,那么今天我们来聊一聊如何打造一款图形化金融工具--股票交易图(K线图). 最近小编在多个开发控件产品群看到有一群 ...

  5. ffplay自定义播放器封装C#接口

    ffplay自定义系列 第一章 自定义播放器接口 第二章 倍速播放 第三章 dxva2硬解渲染 第四章 提供C#接口(本章) 第五章 制作wpf播放器 文章目录 ffplay自定义系列 前言 一.接口 ...

  6. 使用EPPlus(C#)读写Excel

    1. EPPlus概述 EPPlus 是使用Open Office XML格式(xlsx)读写Excel 2007 / 2010文件的.net开发库. 官网: http://epplus.codepl ...

  7. 转:使用EPPlus(C#)读写Excel

    版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/alanzyy/article/deta ...

  8. 使用Prism提供的类实现WPF MVVM点餐Demo

    由于公司开发的技术需求,近期在学习MVVM模式开发WPF应用程序.进过一段时间的学习,感受到:学习MVVM模式,最好的方法就是用MVVM做几个Demo,因为编程里面的东西还是原来的WPF的相关知识.最 ...

  9. python wpf教程_WPF使用IronPython库的简单Demo

    WPF使用IronPython库的简单Demo 一.IronPython和C#交互 IronPython是一个.NET平台上的Python实现,包括了完整的编译器.执行引擎与运行时支持,能够与.NET ...

  10. WPF TreeView 绑定(demo 转)

    WPF TreeView 绑定 2018年01月23日 13:55:32 余生余我 阅读数:563 前台: <TreeView x:Name="tree" ItemsSour ...

最新文章

  1. Java用数组的包文件_在Java中获取包内的类文件数组
  2. 前天在一直Linux根文件系统时提示WARNING: Unable to open an in...
  3. bat tomcat程序在后台执行_Web中间件漏洞之Tomcat篇
  4. linux ps查看进程命令
  5. DRF的序列化——Serializers 序列化组件
  6. web前端自学入门视频教程分享
  7. 浏览器兼容性问题解决方案· 总结
  8. hive cli启动判断hadoop version的问题
  9. C# httpcookie asp.net中cookie的使用
  10. 动易模板——制作前的准备工作
  11. docker安装windows镜像,实战案例
  12. python编程菜鸟_python菜鸟教程
  13. RHCE考试第一天之学习安排计划
  14. R语言初级教程(01): R编程环境的搭建
  15. c语言错误1083,terminal services 无法启动,尝试启动报错误1083
  16. 学完计算机控制系统的感受,管理信息系统学习心得体会(精选5篇)
  17. 【租房合同】2017北京市房屋租赁合同(自行成交版).doc
  18. [转]我的世界观(一)
  19. 英文格式的时间转换为 yyyy-MM-dd 格式
  20. android应用开发完全

热门文章

  1. 【全面解禁!真正的Expression Blend实战开发技巧】第一章 真正的开发中的最佳的做法...
  2. [刘阳Java]_Spring相关配置介绍_第5讲
  3. 如何通过代码设置WPF控件的字体,颜色
  4. glog学习(二):glog主要接口和类分析
  5. STM32(5)——通用定时器基本定时器
  6. 【搜索入门】桐桐的组合
  7. oracle pl/sql 无监听程序
  8. 热烈祝贺新疆.Net俱乐部博客开通——天下博客开通
  9. 转:KVC与KVO机制
  10. linux一些基本知识