ThreadExcecute function is doing encryption of a files using third party dll. So depending upon file size it will vary the encryption time.But If I've run this in parallel for multiple files then definitely it suppose to take less time.
I require your opinion on what approach is good and/or practical for the following scenario.
There is a web application which queries data from SQL server. For example:
Users report to a manager
1. The process by clicking a button is finding who reports to me (manager)
2. So there is a stored procedure written to find the users reporting to the manager
Now, there is a report (rdlc on the web server displayed via reportviewer control) which takes the manager as an input to generate report data for the staff members reporting to that manager. The stored procedure for this report uses existing stored procedure (as in step 2 above) to find the staff members reporting to the manager and then generate required data.
My question is:
1. Is this the right way of doing this
2. Is there a need to develop a separate SQL view just for this report
3. What would be the best approach on doing this.
This always returns true, whether I have notepad open or not, can anyone tell me what I'm doing wrong?
Process current = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcessesByName(current.ProcessName))
if (process.Id != current.Id)
static Mutex _m;
staticvoid Main(string Args)
// Try to open existing mutex.
// If exception occurred, there is no such mutex.
Program._m = new Mutex(true, "Notepad");
// Only one instance.returntrue;
// More than one instance.returnfalse;
What TYPE of exception is thrown? You may be having permission issues or something else... that is, the notepad exists and it's running, but you don't have permission to access it. If you look in the docs, there's 5 different exceptions it can throw, and the situations are very different...
You don't call OpenExisting on the Mutex object. You simple try to create a new instance of the Mutex with the same name. If the object is created, it's the only one in the system. If the create fails, then you know you're not the first instance to run.
You don't create the Mutex in the Catch block. By the time you get there, you never created a mutex in the first place.
Thanks for the reply ... I know I'm the one asking for help here, but I saw this technique all over the internet, including msdn, only with the MSDN example it is done by calling a function in the catch.
Am I overlooking something possibly or misunderstanding?
There is quite a bit more in that example code, than what you have implemented in yours. The issue I was thinking about is the different exception types... you are using Pokemon exception handling (catch 'em all) - but the example catches each exception type and handles it differently.
However, your exception (no handle exists with that name) is telling us the problem, and it's what Dave said it was - it doesn't exist, and you aren't trying to create it, you're trying to "get" it.
Just because you see a technique all over the Internet does not mean that it applies to your situation.
From what I've seen in your code, it suggests you're trrying to make a single instance app. The code you have is not suited for that purpose at all. To make a single instance app, an application first tries to create a Mutex. If it's successfull, it's the first app instance running. If the creation of the Mutex fails, then you know your app is not the only instance running.
Follow the logic in your code snippet and you will see that it does not follow the logic I just laid out.