Search Results

Search found 4 results on 1 pages for 'stanleygu'.

Page 1/1 | 1 

  • Solution 6 : Kill a Non-Clustered Process during Two-Node Cluster Failover

    - by StanleyGu
    Using Visual Studio 2008 and C#, I developed a windows service A and deployed it to two nodes of a windows server 2008 failover cluster. The service A is part of the failover cluster service, which means, when failover occurs at node1, the cluster service will failover the windows service A from node 1 to node 2. One of the tasks implemented by the windows service A is to start, monitor or kill a process B. The process B is installed to the two nodes but is not part of the failover cluster service. When a failover occurs at node1, the cluster service does not failover the process B from node 1 to node 2, and the process B continues running at node1. The requirement is: When failover occurs at node1, we want the process B running at node1 gets killed, but we do not want the process B be part of the failover cluster service. The first idea that pops up immediately is to put some code in an event handler triggered by the failover in the windows service A. The failover effect to the windows service A is similar to using the task manager to kill the process of the windows service A, but there is no event in windows service that can be triggered by killing the process of the window service. The events related to terminating a windows service are OnStop and OnShutDown, but killing the process of windows service A triggers neither of them. The OnStop event can only be triggered by stopping the windows service using Services Control Manager or Services Management Console. Apparently, the first idea is not feasible. The second idea that emerges is to put code into the OnStart event handler of the windows service A. When failover occurs at node 1, the windows service A is killed at node 1 and started at node 2. During the starting, the windows service A at node 2 kills the process B that is running at node 1. It is a workaround and works very well. The C# code implementation within the OnStart event handler is as following: 1.       Capture server names of the two nodes from App.config 2.       Determine server name of the remote node. 3.       Kill the process B running on the remote node. Check here for sample code.  

    Read the article

  • Tip 14 : Solve SmtpClient issues of delayed email and high CPU usage

    - by StanleyGu
    1. It is quite straightforward using SmtpClient class to send out an email 2. However, when you step through the above code executing smtpClient.Send(), you will notice about 2 minutes delay in receiving the email. 3. My first try to solve the issue of delayed email is to set MaxIdleTime=1 4. The first try solves the issue of delayed email very well but introduces another issue: high CPU usage. The CPU usage of my deployed windows service is consistently at 50%, which is much higher than the expected near-zero CPU usage. 5. The second try is to set MaxIdleTime=2, which solves the both issues.    

    Read the article

  • Tip 16 : Open Multiple Documents within Single Application Instance Using C#

    - by StanleyGu
    1.       Using Microsoft Word 2007 as an example, you can open test1.docx and test2.docx at same time. The two documents are opened within single instance of the word application. World application supports command line argument of passing multiple documents. 2.       Again, Using Microsoft Word 2007 as an example, you can open test1.docx first and then test2.docx. The two documents are opened within single instance of the Word application. Word application supports Multiple Document Interface (MDI). 3.       Using Notepad as an example, you receive error message of “The filename, directory name, or volume label syntax is incorrect” if you want to open two documents at the same time. Notepad does not support command line argument of passing multiple documents 4.       Again, using Notepad as an example, you can open test1.txt first and then test2.txt. The two documents are opened to two different instances of Notepad application. Notepad does not support Multiple Document Interface (MDI). 5.       In conclusion, there is nothing you can do trying to rely on System.Diagnostics.Process class to open multiple documents within a single instance of an application because it is controlled by the application itself. The best approach is to read any developer or user guide of the application and make sure: 1. The application supports Multiple Document Interface (MDI) 2. The application provides command line argument of passing multiple documents. Then, you can use Process class and the command line argument syntax to open multiple documents for the application.  

    Read the article

  • Tip 13 : Kill a process using C#, from local to remote

    - by StanleyGu
    1. My first choice is always to try System.Diagnostics to kill a process 2. The first choice works very well in killing local processes. I thought the first choice should work for killing remote process too because process.kill() method is overloaded with second argument of machine name. I pass process name plus remote machine name and call the process.kill() method 3. Unfortunately, it gives me error message of "Feature is not supported for remote machines.". Apparently, you can query but not kill a remote process using Process class in System.Diagnostics. The MSDN library document explicitly states that about Process class: Provides access to local and remote processes and enables you to start and stop local system processes. 4. I try my second choice: using System.Management to kill a process running on a remote machine. Make sure add references to System.Management.dll and System.Management.Instrumentation.dll 5. The second choice works very well in killing a remote process. Just need to make sure the account running your program must be configured to have permission to kill a process running on the remote machine.  

    Read the article

1