silverlight中的多线程和计时器
来源:互联网 发布:淘宝价格区间怎么设置 编辑:程序博客网 时间:2024/06/05 02:08
DispatcherTimer 是SL中很有用的一个计时器对象。也是基础SL 的UI线程
XAML代码:
<UserControl x:Class="Sample.Timer" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="200"><Grid x:Name="LayoutRoot" Background="White"> <!--背景--> <Rectangle Fill="Gold" Stroke="Black" StrokeThickness="3" RadiusX="5" RadiusY="5"/> <!--显示时间--> <TextBlock x:Name="tbkTimer" Width="300" Height="50" FontSize="30" Foreground="Red"/></Grid></UserControl>
后台代码:
using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Windows;using System.Windows.Controls;using System.Windows.Documents;using System.Windows.Input;using System.Windows.Media;using System.Windows.Media.Animation;using System.Windows.Shapes;using System.Windows.Threading;namespace Sample{ public partial class Timer : UserControl {public Timer(){ InitializeComponent(); //创建DispatcherTimer DispatcherTimer timer = new DispatcherTimer(); //设置间隔1秒 timer.Interval = new TimeSpan(0, 0, 1); //创建事件处理 timer.Tick += new EventHandler(timer_Tick); //开始计时 timer.Start();}void timer_Tick(object sender, EventArgs e){ //输出时间 tbkTimer.Text = "当前时间:" + DateTime.Now.ToLongTimeString();} }}
- silverlight中的多线程和计时器
- 关于Silverlight中的多线程的理解
- Windows中的计时器(SetTimer和CreateWaitableTimer)
- Linux2.6 内核中的计时器和列表
- Linux2.6 内核中的计时器和列表
- 2.6 内核中的计时器和列表
- Linux2.6 内核中的计时器和列表
- 2.6 内核中的计时器和列表
- js中的定时器和计时器使用
- js中的定时器和计时器使用
- Java 、Android开发中的多线程编程技术------计时器实例
- Android 开发中的多线程编程技术(例子:计时器)
- Silverlight之DispatcherTimer计时器对象
- silverlight多线程
- 多线程的计时器
- C# 多线程计时器类。
- C# 多线程计时器类
- 服务器计时器、Windows 计时器和线程计时器
- mysql导入中文文本数据乱码
- VS2010 C++最简单的检查内存泄露
- iOS学习之iOS沙盒(sandbox)机制和文件操作之NSFileManager(三)
- 病毒再次来袭
- 挂载虚拟机镜像到单板的某个目录
- silverlight中的多线程和计时器
- 操作framebuffer
- String.Format,DateTime日期时间格式化集锦,备忘录
- HDU 3342 Legal or Not 判断拓补排序能否形成环
- 图论基本概念:
- AMGCL---progect
- Working with Kconfig
- 七种Prolog解释器/编译器
- Cookie技术