Application 类具有用于启动和停止应用程序和线程以及处理 Windows 消息的方法,如下所示:

  • Run 在当前线程上启动应用程序消息循环,并可以选择使某窗体可见。

  • Exit 或 ExitThread 停止消息循环。

  • DoEvents 在您的程序处于某个循环中时处理消息。

  • AddMessageFilter 向应用程序消息泵添加消息筛选器来监视 Windows 消息。

  • IMessageFilter 使您可以阻止引发某事件或在调用某事件处理程序前执行特殊操作。

该类具有用于获取或设置当前线程的区域性信息的 CurrentCulture 和 CurrentInputLanguage 属性。

不能创建此类的实例。

Application.EnableVisualStyles();//Enables visual styles for the application
Application.SetCompatibleTextRenderingDefault(false);//If true, new controls that support UseCompatibleTextRendering use
//the GDI+ based Graphics class for text rendering;
//if false, new controls use the GDI based TextRenderer class;In Visual C# 2005 or later,
//a call to SetCompatibleTextRenderingDefault is automatically generated in the Program.cs file.
Application.Run(new mainFrm());

示例代码:

public class Form1 : Form
{
[STAThread]
public static void Main()
{
// Start the application.
Application.Run(new Form1());
} private Button button1;
private ListBox listBox1; public Form1()
{
button1 = new Button();
button1.Left = ;
button1.Text = "Exit";
button1.Click += new EventHandler(button1_Click); listBox1 = new ListBox();
this.Controls.Add(button1);
this.Controls.Add(listBox1);
} private void button1_Click(object sender, System.EventArgs e)
{
int count = ;
// Check to see whether the user wants to exit the application.
// If not, add a number to the list box.
while (MessageBox.Show("Exit application?", "",
MessageBoxButtons.YesNo)==DialogResult.No)
{
listBox1.Items.Add(count);
count += ;
} // The user wants to exit the application.
// Close everything down.
Application.Exit();
}
}

Application 类的更多相关文章

  1. Android Application类作用简单说明

    每个程序运行时创建一个Application类的对象且只创建一个 Application对象的生命周期是整个程序中最长的,它的生命周期就等于这个程序的生命周期. Application来进行一些,如: ...

  2. [转]Android中Application类的用法

    原文链接:http://www.cnblogs.com/renqingping/archive/2012/10/24/Application.html Application类 Application ...

  3. 【转】Android中Application类用法

    转自:http://www.cnblogs.com/renqingping/archive/2012/10/24/Application.html Application类 Application和A ...

  4. WPF的Application类

    本节主要介绍一下Application类的部分功能,我们首先来看一下如何使用Application类来加载一个窗口: 我们首先创建一个控制台程序,并引入相关的dll,然后修改Main()方法. [ST ...

  5. android application类的用法

    android application类的用法 Application是android系统Framework提供的一个组件,它是单例模式(singleton),即每个应用只有一个实例,用来存储系统的一 ...

  6. Android(java)学习笔记120:Android中的Application类用法

    1.简介 如果想在整个应用中使用全局变量,在java中一般是使用静态变量,public类型:而在android中如果使用这样的全局变量就不符合Android的框架架构,但是可以使用一种更优雅的方式就是 ...

  7. 六,WPF的Application类

    Application.ShutdownMode属性:通过,只要有一个窗口还没有关闭,Application类就保持应用程序处于有效状态,如果这不是所期望的行为,就可以调整该属性. 应用程序事件 Ap ...

  8. android开发之重写Application类

    在android应用开发中,重写Application也算是比较常见的,以前开发的一些程序太过于简单,都不要重写这个类,但是在真正的商业开发中,重写Application类几乎是必做的. 为什么要重写 ...

  9. Android中用Application类实现全局变量

    最近在项目中,遇到了application这个类,开始不知道有什么用,经过学习后才知道它的用途也蛮大的,举个例子,如果想在整个应用中使用全局变量,在java中一般是使用静态变量,public类型:而在 ...

  10. Android学习笔记(三)Application类简介

    每次运行APP时,Application类都保持实例化状态.与Activity不同,配置改变不会导致应用程序重启.通过继承Application类,可以完成一下3项工作: · 对Android运行时广 ...

随机推荐

  1. JavaScript中几种 获取元素的方式

    1.根据id获取元素 document.getElementById("id属性的值"); 2.根据标签名字获取元素 document.getElementsByTagName(& ...

  2. torch7入门(安装与使用)

    http://blog.csdn.net/real_myth/article/details/52291636 1.安装与使用 测试系统是ubuntu14.04LTS,默认安装在-/torch,当然我 ...

  3. MIPI接口LCD屏调试心得(转)

    源: MIPI接口LCD屏调试心得

  4. MySQL Crash Course #13# Chapter 21. Creating and Manipulating Tables

    之前 manipulate 表里的数据,现在则是 manipulate 表本身. INDEX 创建多列构成的主键 自动增长的规定 查看上一次插入的自增 id 尽量用默认值替代 NULL 外键不可以跨引 ...

  5. 查询oracle数据库里面所有的表名

    如果是当前用户,"select * from tab"即可

  6. Python Web学习笔记之面试TCP的15个问题

    网络协议那么多,为什么面试喜欢问TCP?原因无外乎两个:1.TCP协议直接与进程打交道,写网络程序要用:2.TCP协议设计十分精巧,在一个不可靠的IP网络上实现了可靠传输,因为精巧,掌握TCP的原理自 ...

  7. 01: RestfulAPI与HTTP

    1.1 RestfulAPI与HTTP简介 1.什么是RestfulAPI 1.REST直接翻译:表现层状态转移,实质就是一种面向资源编程的方法 2.REST描述的是在网络中client和server ...

  8. 04: 打开tornado源码剖析处理过程

    目录:Tornado其他篇 01: tornado基础篇 02: tornado进阶篇 03: 自定义异步非阻塞tornado框架 04: 打开tornado源码剖析处理过程 目录: 1.1 torn ...

  9. 20145208 蔡野《网络对抗》Exp3 Advanced 恶意代码伪装技术实践

    20145208 蔡野<网络对抗>Exp3 Advanced 恶意代码伪装技术实践 木马化正常软件 思路: 在正常软件包中将原本的程序主文件(平时打开程序用的exe文件)改成dll后缀(或 ...

  10. Nodejs -- 使用koa2搭建数据爬虫

    当前爬虫项目开发所需中间件: cheerio: 则能够对请求结果进行解析,解析方式和jquery的解析方式几乎完全相同 cheerio中文文档 开发参考node - cheerio模块 superag ...