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. (三)github之GIT的导入

    什么是版本管理? git是一款[分散型版本管理]软件,提供了开发过程中不可少的功能,例如记录一款软件添加或者更改源代码的过程,回溯到特定阶段,恢复误删除的文件等. 集中型:将仓库集中放在服务器中,一旦 ...

  2. Python入门之Pycharm开发中最常用快捷键

    要查阅Pycharm的快捷键,当然要看官方文档,https://www.jetbrains.com/help/pycharm/mastering-keyboard-shortcuts.html 编辑类 ...

  3. 06: linux下python开发环境梳理

    1.1 修改~/.bashrc文件 改编终端颜色 alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # User specific aliases ...

  4. 基础知识 - Golang 中的格式化输入输出

    ------------------------------------------------------------ [格式化输出] // 格式化输出:将 arg 列表中的 arg 转换为字符串输 ...

  5. [noip模拟题]科技节 - 搜索 - 位运算优化

    [问题描述] 一年一度的科技节即将到来.同学们报名各项活动的名单交到了方克顺校长那,结果校长一看皱了眉头:这帮学生热情竟然如此高涨,每个人都报那么多活动,还要不要认真学习了?!这样不行!……于是,校长 ...

  6. 《Python程序设计(第3版)》[美] 约翰·策勒(John Zelle) 第 1 章 答案

    判断对错1.计算机科学是计算机的研究.2.CPU 是计算机的“大脑”.3.辅助存储器也称为 RAM.4.计算机当前正在处理的所有信息都存储在主存储器中.5.语言的语法是它的意思,语义是它的形式.6.函 ...

  7. 【TCP/IP详解 卷一:协议】第二十四章 TCP的未来与性能

    来到了TCP的最后一个章节,未来与性能.在当时(1991年)的未来,如今已经部分变为现实,部分就只是历史中的实验. 主要内容: 路径MTU的发现与TCP的结合. 长肥管道 和 高速千兆比网络. 窗口扩 ...

  8. js 二进制转换为16进制数

    <!DOCTYPE html> <html> <head> <title>远程监控</title> </head> <bo ...

  9. Java 打开Excel,往Excel中存入值,保存的excel格式分别是xls和xlsx

    https://mirrors.cnnic.cn/apache/poi/xmlbeans/release/src/ package Excel; import org.apache.poi.hssf. ...

  10. JSONObject获取的值有时候不是String类型,而有时候又是String类型,怎么办呐

    { "weatherinfo": { "city": "深圳", "cityid": "101280601&q ...