主程序调用客程序

方法一:

Process.Start( System.Windows.Forms.Application.StartupPath + "\\SelfUpdate.exe").WaitForExit();

waitforexit()等待当前程序结束,继续执行主程序,"\\“很重要不能忘。

方法二:

ProcessStartInfo info = new ProcessStartInfo();
info.FileName = @"路径\exe的文件名";
info.Arguments = "";
info.WindowStyle = ProcessWindowStyle.Minimized;
Process pro = Process.Start(info);
pro.WaitForExit();

html超链接注意:

<QrCode Code="http://www.XXXX.com/XXX.html?t=w&amp;BussinessType=151&amp;deviceno="></QrCode>

要增加个 转义符号&amp

日志生成方法:

private static readonly ReaderWriterLockSlim _readerWriterLockSlim

= new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

public static void SaveInfoToLog(string info)
{
string path = DateTime.Now.ToString("yyyyMMdd") + ".txt";
string strLogDir = AppDomain.CurrentDomain.BaseDirectory + "\\LogFiles";
if (!Directory.Exists(strLogDir))
{
Directory.CreateDirectory(strLogDir);
}
_readerWriterLockSlim.EnterWriteLock();
using (StreamWriter sw = new StreamWriter(strLogDir + "\\" + path, true, Encoding.UTF8))
{
sw.WriteLine(info);
}
_readerWriterLockSlim.ExitWriteLock();
}

查看printer方法:

Task.Run(() =>
{
 if (!IsPrinterOk(printDocument.PrinterSettings.PrinterName))
 {
// failed printing, do something...
 var form = new Printmessage();
form.ShowInTaskbar = false;
form.ShowDialog();
Debug.WriteLine($">>>>>>>>>>>>>>>>{Thread.CurrentThread.ManagedThreadId}\t failed.");
}
 else
{
 Debug.WriteLine($">>>>>>>>>>>>>>>>>>>>>>{Thread.CurrentThread.ManagedThreadId}\t success.");

}

});

private static bool IsPrinterOk(string name, int checkTimeInMillisec = 2000)
{

System.Collections.IList value = null;
do
{
//checkTimeInMillisec should be between 2000 and 5000
System.Threading.Thread.Sleep(checkTimeInMillisec);
// or use Timer with Threading.Monitor instead of thread sleep

using (System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher("SELECT * FROM Win32_PrintJob WHERE Name like '%" + name + "%'"))
{
value = null;

if (searcher.Get().Count == 0) // Number of pending document.
return true; // return because we haven't got any pending document.
else
{
foreach (System.Management.ManagementObject printer in searcher.Get())
{
value = printer.Properties.Cast<System.Management.PropertyData>().Where(p => p.Name.Equals("Status")).Select(p => p.Value).ToList();
break;
}
}
}
}
while (value.Contains("Printing") || value.Contains("UNKNOWN") || value.Contains("OK"));

return value.Contains("Error") ? false : true;
}

///控制台字体问题

Console.OutputEncoding = System.Text.Encoding.Unicode;

winform 所遇的更多相关文章

  1. 【基于WinForm+Access局域网共享数据库的项目总结】之篇三:Access远程连接数据库和窗体打包部署

    篇一:WinForm开发总体概述与技术实现 篇二:WinForm开发扇形图统计和Excel数据导出 篇三:Access远程连接数据库和窗体打包部署 [小记]:最近基于WinForm+Access数据库 ...

  2. [WinForm]WinForm跨线程UI操作常用控件类大全

    前言 在C#开发的WinForm窗体程序开发的时候,经常会使用多线程处理一些比较耗时之类的操作.不过会有一个问题:就是涉及到跨线程操作UI元素. 相信才开始接触的人一定会遇上这个问题. 为了解决这个问 ...

  3. GJM:C# WinForm开发系列 - DataGridView 使用方法集锦 [转载]

    1.DataGridView实现课程表 testcontrol.rar 2.DataGridView二维表头及单元格合并 DataGridView单元格合并和二维表头.rar myMultiColHe ...

  4. Winform/WPF国际化处理

    1.Winfrom国际化处理方式 ==> Winform中国际化支持可将UI页面和.cs文件分开处理 处理窗体方式如下:1.选择Form窗体设置其--Language(默认中文--Default ...

  5. 【转】Winform程序未捕获异常解决方法 EventType clr20r3 P1

    from:http://blog.csdn.net/chichaodechao/article/details/8294922 在开发winform程序时,用到多线程,在服务器部署后运行,老是自动关才 ...

  6. 使用 .NET WinForm 开发所见即所得的 IDE 开发环境,实现不写代码直接生成应用程序

    直接切入正题,这是我09年到11年左右业余时间编写的项目,最初的想法很简单,做一个能拖拖拽拽就直接生成应用程序的工具,不用写代码,把能想到的业务操作全部封装起来,通过配置的方式把这些业务操作组织起来运 ...

  7. 逆天通用水印支持Winform,WPF,Web,WP,Win10。支持位置选择(9个位置 ==》[X])

    常用技能:http://www.cnblogs.com/dunitian/p/4822808.html#skill 逆天博客:http://dnt.dkil.net 逆天通用水印扩展篇~新增剪贴板系列 ...

  8. 【基于WinForm+Access局域网共享数据库的项目总结】之篇一:WinForm开发总体概述与技术实现

    篇一:WinForm开发总体概述与技术实现 篇二:WinForm开发扇形图统计和Excel数据导出 篇三:Access远程连接数据库和窗体打包部署 [小记]:最近基于WinForm+Access数据库 ...

  9. winform 窗体圆角设计

    网上看到的很多winform窗体圆角设计代码都比较累赘,这里分享一个少量代码就可以实现的圆角.主要运用了System.Drawing.Drawing2D. 效果图 代码如下. private void ...

随机推荐

  1. Q语言-[帝王三国送将辅助]

    纯属自己写的, 玩同一个游戏的朋友,需要送将的, 把需要送的将改名为送, 然后启动辅助即可 本辅助只支持1024x576 191dpi 附上源码 //本源码初始化分辨率1024x576[夏天] Dim ...

  2. 剑指offer(66)机器人的运动范围

    题目描述 地上有一个m行和n列的方格.一个机器人从坐标0,0的格子开始移动,每一次只能向左,右,上,下四个方向移动一格,但是不能进入行坐标和列坐标的数位之和大于k的格子. 例如,当k为18时,机器人能 ...

  3. Linux操作系统中系统调用接口

    进程控制 fork 创建一个新进程 clone 按指定条件创建子进程 execve 运行可执行文件 exit 终止进程 _exit 立即终止当前进程 getdtablesize 进程所能打开的最大文件 ...

  4. Sony索尼数码录音笔MSV格式转换为MP3格式【转】

    本文转载自:http://blog.sina.com.cn/s/blog_4b2c860f0100d78w.html Sony索尼数码录音笔一般存储为WAV格式,有些没有特意修改存储格式的就保存为MS ...

  5. Codeforces Global Round 1 解题报告

    A 我的方法是: #include<bits/stdc++.h> using namespace std; #define int long long typedef long long ...

  6. Cordova 笔记

    npm instal -g cordova 安装 卸载cordova npm unistall cordova -g 安装指定版本 npm install -g cordova@ 1.创建应用项目及目 ...

  7. C语言--第2次作业

    1.本章学习总结 1.1思维导图 1.2本章学习体会及本章代码量 1.2.1学习体会 不同于前几周简单的条件语句等,这一周开始学习循环结构for,while语句,甚至是多种语句嵌套使用,让我直接感受到 ...

  8. GeoJson

    几何对象.特征对象.特征对象集合.

  9. If嵌套

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  10. jquery清除某一结点下的子节点

    jquery清除某一结点下的子节点:这个情况多用于数据的加载中,如果当执行某一操作之后,想重新加载页面,但是又不想整个页面都重新加载,这个时候就可以使用该方法, case:   $("#ta ...