I am working on a program that i already written in Python. But now i'm trying to make same program in c#. Problem isdelay. Thread.sleep() freezes GUI, same thing in python. But i found solution in python with: after(seconds, execute). How ever i don't see clear solution in c#, i was reading some stuff from forums but i just can't fit it in my code. This is what i need to delay:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Threading; namespace Cworm { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void toolTip1_Popup(object sender, PopupEventArgs e) { } private void activate_b_Click(object sender, EventArgs e) { string cstrike; cstrike = pathbox.Text; if (Directory.Exists(cstrike) && File.Exists(cstrike + @"\config.cfg")) // postoji li cstrike folder & config.cfg { string config = cstrike + @"\config.cfg"; // delay for 3 seconds here <----------------------- status.Text = "delayed"; // delay for 3 seconds here <----------------------- backup(config); } else status.Text = "Invalid path"; } private void backup(string config) { string backup_dir = Directory.GetCurrentDirectory(); activate_b.Enabled = false; stop_b.Enabled = true; } private void stop_b_Click(object sender, EventArgs e) { stop_b.Enabled = false; activate_b.Enabled = true; } } }
Thank you in advance!