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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -