c# - Make my program wait for a second before performing an action -
i have :
private void form1_load(object sender, eventargs e) { hide(); string ngdx = "*ngdx"; string atdx = "*atdx"; (;;) { try { string[] convertngdx = directory.getfiles("d:\\folder", ngdx); string[] convertatdx = directory.getfiles("d:\\folder", atdx); foreach (var convertngd in convertngdx) { file.move(convertngd, path.changeextension(convertngd, ".ngd")); } foreach (var convertatd in convertatdx) { file.move(convertatd, path.changeextension(convertatd, ".atd")); } } catch { } } }
i start app , every time .ngdx
, .atdx
file send folder
automatically converts .ngd
, .atd
.
my problem instantly converts them , , want wait second before converting them.
i used system.threading.thread.sleep(1000);
doesn't quite seem work,i think because when run app system.threading.thread.sleep(1000);
called , after second never called again.
the idea every time new .ngdx
or .atdx
send folder
want wait second before converting them.
as alternative using infinite for
loop (which tie ui thread) use filesystemwatcher
. (example)
Comments
Post a Comment