-
Jun 12th, 2014, 05:15 PM
#1
Thread Starter
Hyperactive Member
C# Code to Shutdown Any Excel Process Running Longer Than 1 Minute
I need a method to add at the beginning of my project that will check and see if any Excel processes have been running longer than 1 minute and shut them down if it finds any. I have a method which shuts down all instances of Excel but I only want to kill them if they've neen running longer than 1 minute.
-
Jun 13th, 2014, 04:41 PM
#2
Re: C# Code to Shutdown Any Excel Process Running Longer Than 1 Minute
What you should so is:
- Create a new thread
- Create an infinite loop on that thread
- Continuously check if any Excel program opens
- If an Excel program opens, create a new timer and set it's interval to 1 minute
- After that minute is up, check if the Excel program is still open. If it is, then close it.
Here are some material on the different subjects mentioned:
Threading
Threading Tutorial - MSDN - Link Here
Threading (C# and Visual Basic.Net) - MSDN - Link Here
Infinite Loop
How do I create an infinite loop - MSDN C# Forums - Link Here
C# While - Dot Net Perls - Link Here
Excel
Get instance of Excel application with C# by Handle - Stack Overflow Forums - Link Here
How can I open the current instance of Excel from my application? - Stack Overflow Forums - Link Here
Processes
How to terminate a process in c# - MSDN C# Forums - Link Here
Process.Close Method - MSDN - Link Here
-
Jun 13th, 2014, 05:01 PM
#3
Re: C# Code to Shutdown Any Excel Process Running Longer Than 1 Minute
1minute even if someone is using it?If not then you can also add this to your thoughs if you need the excel to be idle.
http://www.vbforums.com/showthread.p...77#post4267177
(It's in VB but i bleed these days with C# and i should share the opposite bleeding )
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jun 16th, 2014, 03:55 PM
#4
Thread Starter
Hyperactive Member
Re: C# Code to Shutdown Any Excel Process Running Longer Than 1 Minute
saptor, yes, this is an automated process and if an Excel instance has been running longer than 1 minute then it's definitely in need of whacking. And yes, I too was a VB.NET man but they tied me down and forced me to start learning C#. Oh well, could be worse. Could be raining.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|