Feedback

Benutzereingaben blockieren [Übersetzung]

Sprache: C#

Die in C# übersetzte Version von diesem Snippet von Tim Hartwig: http://dotnet-snippets.de/dns/benutzereingaben-blockieren-SID333.aspx
[DllImport("user32")]
public static extern bool BlockInput(bool BlockIt);

/// <summary>
/// Blockiert die Eingaben des Benutzers für eine bestimmte Zeit.
/// </summary>
/// <param name="time">Die Zeit der Blockierung in Millisekunden.</param>
public void BlockUserInput(int time)
{
    BlockInput(true);
    System.Threading.Thread.Sleep(time);
    BlockInput(false);
}

// Beispielaufruf für die Blockierung von 10 Sekunden:
BlockUserInput(10000);
[DllImport("user32")]
public static extern bool BlockInput(bool BlockIt);

/// <summary>
/// Blockiert die Eingaben des Benutzers für eine bestimmte Zeit.
/// </summary>
/// <param name="time">Die Zeit der Blockierung in Millisekunden.</param>
public void BlockUserInput(int time)
{
    BlockInput(true);
    System.Threading.Thread.Sleep(time);
    BlockInput(false);
}

// Beispielaufruf für die Blockierung von 10 Sekunden:
BlockUserInput(10000);