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. GDPR给安全的影响

    违反GDPR的代价过于巨大,因而你不得不为那些预料不到的后果考虑,而且因为无法使用Whois数据,无形中也扩大了威胁界面.因为GDPR的存在,可供黑客入侵的威胁界面显著增长,不是增加了一点点,而是翻了 ...

  2. 【运维技术】Nexus私服安装配置常用问题

    maven私服安装配置 软件安装及基本配置 安装配置 # 安装jdk,参考其他教程 mkdir -p /app/nexus2 # 创建目录 wget https://download.sonatype ...

  3. Python3 tesseract加载chi_sim异常停止工作

    Python3 tesseract加载chi_sim异常停止工作 原因: chi_sim.traineddata 和 tesseract3.0.2 版本不一致: 解决方案: 下载tesseract3. ...

  4. BZOJ 1049 数字序列(LIS)

    题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1049 题意:给出一个数列A,要求:(1)修改最少的数字使得数列严格递增:(2)在( ...

  5. cogs 444. [HAOI2010]软件安装

    ★★☆   输入文件:install.in   输出文件:install.out   简单对比 时间限制:1 s   内存限制:128 MB [问题描述]现在我们的手头有N个软件,对于一个软件i,它要 ...

  6. 【前端】javascript+jQuery实现旋转木马效果轮播图slider

    实现效果: 实现原理: 技术栈: javascript+jQuery+html+css 实现步骤: // 0. 获取元素 // 1. 鼠标放置到轮播图上,显示两侧的控制按钮,移开后隐藏 // 2. 为 ...

  7. python3+pyqt5 +eric5安装配置

    一.大纲内容: 1.预备PC环境: 2.预备安装程序: 2.1.下载Python3.2 2.2.下载PyQt4 2.3.下载Eric5 3.安装配置步骤: 3.1.安装Pyhon3.2 3.2.安装P ...

  8. P3939 数颜色

    目录 题目 思路1(待修莫队) 思路2(vector+二分) 代码1 代码2 题目 P3939 数颜色 思路1(待修莫队) 哇,这不是莫队模板题吗 3e5,TLE45分 不行 我有信仰啊 pow(n, ...

  9. js媒体查询设置根字号

    !function(n){var e=n.document,t=e.documentElement,i=750,d=i/50,o="orientationchange"in n?& ...

  10. 桌面共享UDP组播实现

    组播(Multicast)传输:在发送者和每一接收者之间实现点对多点网络连接.如果一台发送者同时给多个的接收者传输相同的数据,也只需复制一份的相同数据包.它提高了数据传送效率.减少了骨干网络出现拥塞的 ...