最近项目需要试用windows服务来监控一些数据的处理

protected override void OnStart(string[] args)
{

while(true)
{
try
{
workflow.ProcessWorkFlowMQ();
Thread.Sleep(150);
}
catch (Exception e1)
{
Logger.Error(e1.Message);
}
}
}

 

如上代码会造成 服务器安装成功后无法通过windows服务管理进行启动停止.比如说需要更换运行的服务器帐号就无法操作.

分析原因是因为OnStart方法无法执行结束.造成的.所以需要使用多线程来处理

OnStart方法内使用多线程 OnStop方法内部停止循环线程.测试通过服务可以正常启动停止.

代码如下

protected override void OnStart(string[] args)
{

Logger.Error("工作流监控信息启动!" + Environment.NewLine);
thread = new Thread(new ThreadStart(StartProcess));//启用另外一个线程来处理业务.否则 OnStart方法执行不完.服务无法进行停止启动操作.
thread.Start();

}

protected void StartProcess()
{
int i = 0;
while (true)
{

try
{
workflow.ProcessWorkFlowMQ();
Thread.Sleep(150);
i = 0;
}
catch (Exception e1)
{
//Logger.Error(e1.Message);
// i++;
// Thread.Sleep(500 * i);
// if (i == 200)
// {
// thread.Abort();
// }
}
}
}

protected override void OnStop()
{
thread.Abort();
}

posted @ 2012-02-11 23:34 暗香浮动 阅读(4) 评论(0) 编辑

USE master;
GO
DECLARE @SQL VARCHAR(MAX);
SET @SQL=''
SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID)
FROM master..sysprocesses
WHERE dbid=DB_ID('cmistest');

EXEC(@SQL);

GO

ALTER DATABASE cmistest SET multi_user

posted @ 2011-08-05 22:53 暗香浮动 阅读(12) 评论(0) 编辑

restore database [game798bbs]
from disk='F:\game798bbs_db_201101020300.BAK'  with replace,

 file=1
,move 'dnt.game798.com_Data' to 'E:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\game798bbs.MDF'
,move 'dnt.game798.com_Data2' to 'E:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\game798bbs2.MDF'
,move 'dnt.game798.com_Data3' to 'E:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\game798bbs3.MDF'
,move 'dnt.game798.com_Log' to 'E:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\game798bbs.ldf'
,move 'dnt.game798.com_Log2' to 'E:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\game798bbs2.ldf'

posted @ 2011-01-10 23:52 暗香浮动 阅读(141) 评论(0) 编辑

让访问的IE8自动调用IE7的渲染模式,这样可以保证最大的兼容性,方法如下:

  只需要在页面中加入如下HTTP meta-tag:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
  只要IE8一读到这个标签,它就会自动启动IE7兼容模式,保证页面完整展示.

  还有一种方法是针对整个网站的,在IIS中加入如下描述符就可以有相同的效果,当然这么做范围更广.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
    <httpProtocol>
      <customHeaders>
        <add name="X-UA-Compatible" value="IE=EmulateIE7">
      </customHeaders>
    </httpProtocol>
</system.webServer>
</configuration>

posted @ 2010-10-08 10:08 暗香浮动 阅读(430) 评论(0) 编辑

i run Package load analyzer one time it create two Directory for store the analyzed result  eg: (Default) and (NativeImage) .
the directory of  (Default ) not only include the devenv.exe's  analyzed result but also they other (like the outlook.exe's  analyzed result)
i want to know when i run the visual studio not allow the Package load Analyzer to run automatic.  

----------------------------

Those two folders are created by the .net framework when fusion log binding is enabled. The package load analyzer should have turned these off after analyzing your package.

However, you can also turn this off by running the fuslogvw.exe utility. Select the "Settings..." button, then select the "Log disabled" radio button, then close the fuslogvw.exe utility. This will reset the registry settings responsible for turning on the fusion logging.

The fuslogvw.exe utility should be in your program files\Microsoft SDKs\Windows\v6.0A\Bin folder.

posted @ 2010-09-08 10:22 暗香浮动 阅读(24) 评论(0) 编辑
摘要: 近来需要从两个产品合并成一个产品. 命名空间也要进行一下统一设定.修改的过程中发现.很多文件在vss里面是进行了pin的. unpin的话保守估计也有一两千个文件.所以就想看看是不是可以用批量处理的方式来进行.看了看vss的帮助可以使用命令行处理的.遂写了一个批处理文件.执行的时候 如果文件的pin不是在最后的话就无法进行unpin操作.提示 version not found. 无奈上网查找发现...阅读全文
posted @ 2010-07-09 10:31 暗香浮动 阅读(182) 评论(0) 编辑
摘要: 工作流跟踪服务数据库通过 Windows Workflow Foundation 中的 SQL 跟踪服务,您可以添加有关工作流及其关联活动的跟踪信息。SqlTrackingQuery 类提供对包含在跟踪数据库中的数据的高级别访问。但是,您也可以直接查询 SQL 跟踪服务数据库视图以获取更多详细信息。这些视图直接映射到基础 SQL 跟踪服务表架构。SQL 跟踪服务数据库表以下信息概述了 SQL 跟踪...阅读全文
posted @ 2010-04-21 11:38 暗香浮动 阅读(162) 评论(0) 编辑
摘要: 工作中经常需要生成不重复的随机字符串。使用random来生成的话。短时间内生成的重复太多如这篇文章的 http://www.cnblogs.com/smhy8187/articles/888729.html现发现关于重复太多也是有办法解决的 就是Random类定义成 静态类.和这篇文章的http://www.cnblogs.com/insus/articles/1396908.html我都试验了。...阅读全文
posted @ 2009-12-07 15:38 暗香浮动 阅读(165) 评论(0) 编辑
摘要: 有些所见即所得编辑器生成的样式可能会受到网站定义的css样式。造成编辑的效果和现实的效果不一致的问题。但是一直没找到截断上层所有样式对下层影响的办法。今天意识到iframe可能可以解决这个问题。测试了一下目前还没发现什么问题。如果有更好的办法的话麻烦看到的告知一下。去掉iframe边框 frameborder=”no” 微软的浏览器要加这个。阅读全文
posted @ 2009-11-27 12:39 暗香浮动 阅读(98) 评论(0) 编辑
摘要: w3wp.exe进程会产生一个日志文件 在 C:\Windows\temp\pipe.log 无休止增长这个日志文件会无休止的增长。造成系统速度变慢,经常是c盘只剩下0字节。请问怎么停掉这个进程对日志的记录。查了一些资料有人说是clrprofile.exe造成的。但是我没有记得我有运行过这个程序。或者是机器上运行了这个程序但是我不知道在哪儿。不知道是不是这个原因。快被折磨死了。额以上问题发在msd...阅读全文
posted @ 2009-11-18 17:14 暗香浮动 阅读(196) 评论(0) 编辑