- 热门文章:
- · 在.Net中监控Processes和Threads(1)
- · Custom Thread Pooling Template
- · 把昨天写的东西的代码公布出来。哎。。真恶心。
- · C#算法-----(一)选择排序
- · C#算法----(二)插入排序
- · C#算法----(三)希尔排序
- · C#算法-------(四)快速排序
- · C#算法----(三)希尔排序 (solarsoft原创)
- · C#算法----(二)插入排序 (solarsoft原创)
- · 从csdn上看到的一些文章,好象有人转过,再转一次吧——C#算法-----(一)选择排序 (solarsoft原创)
- · 恢复URL字符串
- · 是不是这个?
上一篇:提供一个:用多线程模拟多用户访问站点情况! >>
thread pool
public class CustomWizard : IDTWizard
{
public void Execute(object application, int hwndOwner,
ref object[] contextParams, ref object[] customParams,
ref EnvDTE.wizardResult retval)
{
string lProjName = (string)contextParams[1];
string lSolnName = (string)contextParams[2];
if (!Directory.Exists (lSolnName))
Directory.CreateDirectory (lSolnName);
_DTE lApp = (_DTE)application;
_Solution lSoln = lApp.Solution;
lSoln.Create (lSolnName, lProjName);
lSoln.AddFromTemplate(mProjPath,lSolnName,lProjName,false);
}
// NOTE: change this to the path where you store the downloaded files
private const string mProjPath =
@"C:\C#Today\CustomWizards\ThreadPoolTemplate.csproj";
}
The code block above is all we need for our custom wizard component. The first thing we do in this method is to retrieve the names of the project and the solution that is input by the user in the New Project dialog box. Once that is done, we check to see if the user input path exists, and if not, we use the System.IO.Directory class to create the specified folders. We then use the Solution object from the Visual Studio .NET object model to create a new solution and project based on our ThreadPool classes. We use the AddFromTemplate method of the Solution class to copy over the project files from the thread pool project.
Readers should change the mProjPath variable to point to the location where they have stored the ThreadPoolTemplate.csproj and ThreadPool.cs files.
The .vsdir file for this project template is shown below. We used the Guidgen tool to generate a unique GUID.
Thread Pooled Application.vsz|0|0|0|Generates a
thread pool class.|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|4553|0|0
The .vsz file is as shown below.
VSWIZARD 7.0
Wizard=CustomWizardNS.CustomWizard
Attached Sample Code
The attached sample code contains the CustomWizard and ThreadPoolTemplate projects, and the support vsdir and vsz files.
Please carry out the following steps to set up this sample:
1. Copy the ThreadPool.cs and ThreadPoolTemplate.csproj files to C:\C#Today\CustomWizards. If you need to copy these to a different path, you will have to change the mProjPath member variable in the CustomWizard class from the CustomWizard project.
2. Copy the Thread Pooled Application.vsdir and Thread Pooled Application.vsz files to C:\Program Files\Microsoft Visual Studio.NET\VC#\CSharpProjects. Note that this path will be different if you have installed Visual Studio .NET in a different location. Substitute your install path for C:\Program Files\Microsoft Visual Studio.NET.
3. Compile the CustomWizard project.
4. Copy CustomWizard.dll to C:\Program Files\Microsoft Visual Studio.NET\Common7\IDE. This is again assuming the default install path for Visual Studio .NET.
5. Run the following command on the file copied in the previous step. This registers the managed component as a COM component.
regasm CustomWizard.dll
The following screen shot shows our custom project template in the New Project dialog box.
Conclusion
Custom project templates and wizards are a great way for developers to write boilerplate code once, and have it automatically generated for subsequent use. Visual Studio .NET makes it fairly easy to write these custom wizards, and the code for hooking up a custom template is little more than a few lines of code, as shown in this article@#s sample. Any canned code that is copied over and over again for new projects should be a prime candidate for a custom project template.
Happy .NETing.
下一篇:在.Net中监控Processes和Threads(1) >>
相关文章:
- · C#小游戏-------猜数字 (solarsoft原创)
- · 简繁体转换例程
- · 给你一个MD5算法
- · 如何获得一个6位长随机数
- · 关于字符窜和数字分离
- · 密码的故事 (ST:MS,Author:Billy Hollis )
- · 呵呵,泼点儿凉水。
- · 将字符串中的数字和字符分离的技术例如(the9 city)分解成(the city)和9
- · LinkedQueue的实现
- · C#的BinaryTree实现
- · 给贝贝的,Base64编码(带有Q和B编码)——VB.NET
- · Huffman with Short dictionary压缩算法(VB.NET Source)
- · 上面提到的原代码(C语言)—1
- · 上面提到的原代码(C语言)—2
- · 找到了,JPG格式原理。
- · Huffman 编码简介(讲解的更好一些,有C的分析)
- · Huffman编码原理
- · 浅谈图像压缩算法(好文章。看看吧。再别说不了解JPG的原理了)
- · A Good 31 bit Random Number Generator Class
- · 一棵C#写的树(1) he_x(原作)
- · 把哪天纯数字化文本框的WEB控件代码贴出来。
- · 利用Repeater控件显示主-从关系数据表
- · 一个简单O/R M组件(HFSoft.Data).NET
- · 开发手记(九)——在文件菜单中记录最近使用过的文件
- · 开发手记(八)——ActiveBar控件中的利器(1)
- · 控件代码共享--日期选择控件
- · 功能增强的进度条控件(源码)
- · 改变 PropertyGrid 控件的编辑风格(4)——加入选择列表
- · 改变 PropertyGrid 控件的编辑风格(3)——打开对话框
- · 改变 PropertyGrid 控件的编辑风格(2)——编辑多行文本
- · 改变 PropertyGrid 控件的编辑风格(1)——加入日期控件
- · 一个记录程序运行时间表的控件
- · activebar控件
- · 怎样自定义一个服务器端的控件
- · 在word中如何控制graph控件
- · 通过CDO组件对NNTP服务器发送消息
- · 为.net中的ListBox控件添加双击事件
- · 关 SQLDMO 组件在一些用法!
