![]() |
|
VB.NET Freeze Windows Script - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: VB.NET Freeze Windows Script (/Thread-VB-NET-Freeze-Windows-Script) |
VB.NET Freeze Windows Script - kokiprik - 02-12-2018 This simple script can freeze windows if the form is selected. Code: Public Class Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim a As New Label
Do Until a.Text = "b"
Application.DoEvents()
Try
Do Until a.Text = "b"
Application.DoEvents()
Try
Catch exea As Exception
End Try
Loop
Catch ex As Exception
End Try
Loop
End Sub
End ClassRE: VB.NET Freeze Windows Script - Confidential - 04-29-2018 I haven't tested, but this is a cool little script. Nice job, man. RE: VB.NET Freeze Windows Script - Bish0pQ - 04-29-2018 I wouldn't even know why you'd use this but it's all about locking the main thread. Your code is even pretty long for just locking the main thread. You could do that in a single line or to keep it more clear: You also don't need a timer at all. To everyone still using VB.NET I highly recommend switching to C#. In VB.NET: Spoiler:Code: Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
While True
'This will lock the UI thread (main thread)
End While
End Sub
End ClassIn C#: Spoiler:Code: using System;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
while (true)
{
//Do nothing
}
}
}
} |