he .NET Framework uses a hub and spoke model to package and deploy resources. The hub is the main assembly that contains the nonlocalizable executable code and the resources for a single culture, called the neutral or default culture. The default culture is the fallback culture for the application. Each spoke connects to a satellite assembly that contains the resources for a single culture, but does not contain any code.
There are several advantages to this model:
-
You can incrementally add resources for new cultures after you have deployed an application. Because subsequent development of culture-specific resources can require a significant amount of time, this allows you to release your main application first, and deliver culture-specific resources at a later date.
-
You can update and change an application’s satellite assemblies without recompiling the application.
-
An application needs to load only those satellite assemblies that contain the resources needed for a particular culture. This can significantly reduce the use of system resources.
However, there are also disadvantages to this model:
-
You must manage multiple sets of resources.
-
The initial cost of testing an application increases, because you must test several configurations. Note that in the long term it will be easier and less expensive to test one core application with several satellites, than to test and maintain several parallel international versions.
Detail in http://msdn.microsoft.com/en-us/sb6a8618.aspx
Option 1: Modify the registry info
32bit OS: HKLMSoftwareMicrosoftWindows NTCurrentVersionRegisteredOrganization
64bit OS: HKLMSoftwareWow6432NodeMicrosoftWindows NTCurrentVersionRegisteredOrganization
It’s according to the following MSDN library documentation:
#Template Parameters
http://msdn.microsoft.com/en-us/library/eehb4faa.aspx
For the AssemlyCompany (CompanyName) in AssemblyInfo, it’s $registeredorganization$ which uses value from registry key value from HKLMSoftwareMicrosoftWindows NTCurrentVersionRegisteredOrganization.
(For 64 bit OS, the registry key is HKLMSoftwareWow6432NodeMicrosoftWindows NTCurrentVersionRegisteredOrganization)
Option 2: Modify the template file
Open the template package and customize assemblyInfo file. Please remember to customize this file both in the ProjectTemplates folder and ProjectTemplatesCache folder.
For example:
For VB.NET Winform project, I should modify assemblyInfo file in:
…Microsoft Visual Studio 9.0Common7IDEProjectTemplatesVisualBasicwindows1033WindowsApplication.zip
and
…Microsoft Visual Studio 9.0Common7IDEProjectTemplatesCacheVisualBasicWindows1033WindowsApplication.zip
There are many commonly performed operations that can take a long time to execute. For example:
- Image downloads
- Web service invocations
- File downloads and uploads (including for peer-to-peer applications)
- Complex local computations
- Database transactions
- Local disk access, given its slow speed relative to memory access
Operations like these can cause your user interface to hang while they are running. When you want a responsive UI and you are faced with long delays associated with such operations, the BackgroundWorker component provides a convenient solution.
The BackgroundWorker component gives you the ability to execute time-consuming operations asynchronously (“in the background”), on a thread different from your application’s main UI thread. To use a BackgroundWorker, you simply tell it what time-consuming worker method to execute in the background, and then you call the RunWorkerAsync method. Your calling thread continues to run normally while the worker method runs asynchronously. When the method is finished, the BackgroundWorker alerts the calling thread by firing the RunWorkerCompleted event, which optionally contains the results of the operation.
The BackgroundWorker component is available from the Toolbox, in the Components tab. To add a BackgroundWorker to your form, drag the BackgroundWorker component onto your form. It appears in the component tray, and its properties appear in the Properties window.
To start your asynchronous operation, use the RunWorkerAsync method. RunWorkerAsync takes an optional object parameter, which can be used to pass arguments to your worker method. The BackgroundWorker class exposes the DoWork event, to which your worker thread is attached through a DoWork event handler.
The DoWork event handler takes a DoWorkEventArgs parameter, which has an Argument property. This property receives the parameter from RunWorkerAsync and can be passed to your worker method, which will be called in the DoWork event handler. The following example shows how to assign a result from a worker method called ComputeFibonacci. It is part of a larger example, which you can find at How to: Implement a Form That Uses a Background Operation.
四、线程池和定时器——多线程的自动管理
在多线程的程序中,经常会出现两种情况。一种情况下,应用程序中的线程把大部分的时间花费在等待状态,等待某个事件发生,然后才能给予响应;而另外一种情况则是线程平常都处于休眠状态,只是周期性地被唤醒。在.net framework里边,我们使用ThreadPool来对付第一种情况,使用Timer来对付第二种情况。
ThreadPool类提供一个由系统维护的线程池——可以看作一个线程的容器,该容器需要Windows 2000以上版本的系统支持,因为其中某些方法调用了只有高版本的Windows才有的API函数。你可以使用 ThreadPool.QueueUserWorkItem()方法将线程安放在线程池里,该方法的原型如下:
//将一个线程放进线程池,该线程的Start()方法将调用WaitCallback代理对象代表的函数
public static bool QueueUserWorkItem(WaitCallback);
//重载的方法如下,参数object将传递给WaitCallback所代表的方法
public static bool QueueUserWorkItem(WaitCallback, object);
阅读全文…
一.多线程的概念
Windows是一个多任务的系统,如果你使用的是windows 2000及其以上版本,你可以通过任务管理器查看当前系统运行的程序和进程。什么是进程呢?当一个程序开始运行时,它就是一个进程,进程所指包括运行中的程序和程序所使用到的内存和系统资源。而一个进程又是由多个线程所组成的,线程是程序中的一个执行流,每个线程都有自己的专有寄存器(栈指针、程序计数器等),但代码区是共享的,即不同的线程可以执行同样的函数。多线程是指程序中包含多个执行流,即在一个程序中可以同时运行多个不同的线程来执行不同的任务,也就是说允许单个程序创建多个并行执行的线程来完成各自的任务。浏览器就是一个很好的多线程的例子,在浏览器中你可以在下载JAVA小应用程序或图象的同时滚动页面,在访问新页面时,播放动画和声音,打印文件等。
阅读全文…
近期评论