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. MySQL Crash Course #10# Chapter 19. Inserting Data

    INDEX BAD EXAMPLE Improving Overall Performance Inserting Multiple Rows INSTEAD OF Inserting a Singl ...

  2. python文件操作-r、w、a、r+、w+、a+和b模式

    对文件操作的基本步骤 f=open('a.txt','r',encoding='utf-8') data=f.read() print(data) f.close() 文件的打开和关闭使用open() ...

  3. Python3.x:抓取百事糗科段子

    Python3.x:抓取百事糗科段子 实现代码: #Python3.6 获取糗事百科的段子 import urllib.request #导入各类要用到的包 import urllib import ...

  4. Android 实践项目开发一

    这次做的项目是—手机地图系统 本次实验的功能是,为用户提供需要的目标定位系统定位处理,即用户设置一个目标后, 可以在后台启动一个Service,能够定时读取GPS数据已获得用户当前所在的位置信息, 并 ...

  5. win7 + MySQL 5.6.35 免安装版部署

    之前项目开发一直用的asp.net技术,所以数据库自然而然的就用的Sql Server了,最近想着手看一下MySQL数据库,部署免安装版的MySQL的过程记录一下. 准备工作:window 7   6 ...

  6. 常用maven命令总结

    常用Maven命令: mvn -v //查看版本 mvn archetype:create //创建 Maven 项目 mvn compile //编译源代码 mvn test-compile //编 ...

  7. BZOJ 2141 排队(树状数组套treap)

    题目链接:http://61.187.179.132/JudgeOnline/problem.php?id=2141 题意:给出一个数列A,每次交换两个数的位置.输出交换后逆序对的个数. 思路:首先, ...

  8. Python3基础 tuple 通过拆分元素 把元组的数据删除

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...

  9. 从bios启动说起

    如果从bios启动说起的话,BIOS去加载bootloader,bootloader去加载操作系统,那么bootloader是怎么找到操作系统的呢?经过一些流程后,它会去找grub:然后通过grub提 ...

  10. [luogu 2458][SDOI2006]保安站岗

    题目描述 五一来临,某地下超市为了便于疏通和指挥密集的人员和车辆,以免造成超市内的混乱和拥挤,准备临时从外单位调用部分保安来维持交通秩序. 已知整个地下超市的所有通道呈一棵树的形状:某些通道之间可以互 ...