Click here to Skip to main content
15,895,423 members
Home / Discussions / C#
   

C#

 
QuestionC# cross compile Pin
Chris-197323-Jun-17 3:47
Chris-197323-Jun-17 3:47 
AnswerRe: C# cross compile Pin
Afzaal Ahmad Zeeshan23-Jun-17 4:28
professionalAfzaal Ahmad Zeeshan23-Jun-17 4:28 
AnswerRe: C# cross compile Pin
Eddy Vluggen23-Jun-17 7:08
professionalEddy Vluggen23-Jun-17 7:08 
QuestionVisual Studio extension - Watch window item selection Pin
Abyss22-Jun-17 9:28
Abyss22-Jun-17 9:28 
QuestionEnd the Scheduled Task if it is running for more than couple of hours C# code Pin
indian14322-Jun-17 8:33
indian14322-Jun-17 8:33 
AnswerRe: End the Scheduled Task if it is running for more than couple of hours C# code Pin
Eddy Vluggen22-Jun-17 8:49
professionalEddy Vluggen22-Jun-17 8:49 
GeneralRe: End the Scheduled Task if it is running for more than couple of hours C# code Pin
indian14322-Jun-17 9:13
indian14322-Jun-17 9:13 
GeneralRe: End the Scheduled Task if it is running for more than couple of hours C# code Pin
Eddy Vluggen22-Jun-17 9:44
professionalEddy Vluggen22-Jun-17 9:44 
I got time to do both Smile | :)

C#
using System;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Process[] processes = System.Diagnostics.Process.GetProcesses();
            foreach (Process process in processes)
                if (!process.Responding)
                    SendMail(process.ProcessName);

            Console.ReadLine();
        }

        static void SendMail(string who)
        {
            Console.WriteLine(who + " is not responding.");
        }
    }
}
This could be run from the taskscheduler as well, or you may run it in a loop every once in a while. Would depend heavily on what you want from it; you may want to verify that emailing works, and that there is an alternative way to communicate if emailing suddenly fails.

You may want to include other checks, as the Process-class contains more information on the application that is running. Stuff like memory-useage and the debug-output of those Processes[^]. If you decide to guard all applications on hogging cpu and memory, you also have more control over other stuff that may potentially drown out resources for your own application, and effectively an early-warning system for malware Smile | :)

In that case you may want to pass the entire Process-object, instead of just its name like I did. Another sidenote is that the "Responding"-property is used to test whether applications with a GUI are still responsive. You may want to fiddle with the different CPU-time counts, like the TotalProcessorTime. It would probably be more accurate for console-applications.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]

Questionhow to remove Flag status from Outlook by c# programming or register edit Pin
Member 1323094822-Jun-17 2:38
Member 1323094822-Jun-17 2:38 
AnswerRe: how to remove Flag status from Outlook by c# programming or register edit Pin
Chris Quinn22-Jun-17 3:09
Chris Quinn22-Jun-17 3:09 
AnswerRe: how to remove Flag status from Outlook by c# programming or register edit Pin
Eddy Vluggen22-Jun-17 4:21
professionalEddy Vluggen22-Jun-17 4:21 
GeneralRe: how to remove Flag status from Outlook by c# programming or register edit Pin
Member 1323094822-Jun-17 20:21
Member 1323094822-Jun-17 20:21 
GeneralRe: how to remove Flag status from Outlook by c# programming or register edit Pin
Pete O'Hanlon22-Jun-17 21:23
mvePete O'Hanlon22-Jun-17 21:23 
Question[SOLVED] Unify Methods; Parameters one or two IEnums<T> Pin
atrus271119-Jun-17 22:02
atrus271119-Jun-17 22:02 
AnswerRe: Unify Methods; Parameters one or two IEnums<T> Pin
Richard Deeming20-Jun-17 0:56
mveRichard Deeming20-Jun-17 0:56 
GeneralRe: Unify Methods; Parameters one or two IEnums<T> Pin
atrus271120-Jun-17 2:19
atrus271120-Jun-17 2:19 
GeneralRe: Unify Methods; Parameters one or two IEnums<T> Pin
Richard Deeming20-Jun-17 2:25
mveRichard Deeming20-Jun-17 2:25 
GeneralRe: Unify Methods; Parameters one or two IEnums<T> Pin
atrus271120-Jun-17 2:39
atrus271120-Jun-17 2:39 
PraiseRe: Unify Methods; Parameters one or two IEnums<T> Pin
atrus271120-Jun-17 20:32
atrus271120-Jun-17 20:32 
Questionbehavior of Value Tuples in .NET 4.7 Pin
BillWoodruff19-Jun-17 6:24
professionalBillWoodruff19-Jun-17 6:24 
AnswerRe: behavior of Value Tuples in .NET 4.7 Pin
Nathan Minier19-Jun-17 7:05
professionalNathan Minier19-Jun-17 7:05 
GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
BillWoodruff20-Jun-17 6:36
professionalBillWoodruff20-Jun-17 6:36 
GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
Nathan Minier20-Jun-17 7:34
professionalNathan Minier20-Jun-17 7:34 
AnswerRe: behavior of Value Tuples in .NET 4.7 Pin
Eddy Vluggen19-Jun-17 21:55
professionalEddy Vluggen19-Jun-17 21:55 
GeneralRe: behavior of Value Tuples in .NET 4.7 Pin
BillWoodruff20-Jun-17 6:34
professionalBillWoodruff20-Jun-17 6:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.