asynchronous - c# how to set the code run at final -


i need set line of code run after has finish run. know how that?

private void scanbt_click(object sender, eventargs e)         {             var folder = @"c:\users\shen\desktop\lenzocr\lenzocr\windowsformsapplication1\imagefile";              directoryinfo directoryinfo;             fileinfo[] files;             directoryinfo = new directoryinfo(folder);             files = directoryinfo.getfiles("*.jpg", searchoption.alldirectories);              var processimagesdelegate = new processimagesdelegate(processimages2);             processimagesdelegate.begininvoke(files, null, null);               **//here line of code need run after finish run             system.io.file.delete(@"c:\users\shen\desktop\lenzocr\tempfolder\temppic.jpg");**         }          private void processimages2(fileinfo[] files)         {             var comparableimages = new list<comparableimage>();              var index = 0x0;              foreach (var file in files)             {                 if (exit)                 {                     return;                 }                  var comparableimage = new comparableimage(file);                 comparableimages.add(comparableimage);                 index++;             }              index = 0;              similarityimagessorted = new list<similarityimages>();             //messagebox.show("here"+singlefileinfo.fullname);             var fileimage = new comparableimage(singlefileinfo);              (var = 0; < comparableimages.count; i++)             {                 if (exit)                     return;                  var destination = comparableimages[i];                 var similarity = fileimage.calculatesimilarity(destination);                 var sim = new similarityimages(fileimage, destination, similarity);                 similarityimagessorted.add(sim);                 index++;             }              similarityimagessorted.sort();             similarityimagessorted.reverse();             similarityimages = new bindinglist<similarityimages>(similarityimagessorted);              var buttons =                 new list<button>                     {                         scanbt                     };              if (similarityimages[0].similarity > 70)             {                 con = new system.data.sqlclient.sqlconnection();                 con.connectionstring = "data source=shen-pc\\sqlexpress;initial catalog=characterimage;integrated security=true";                 con.open();                  string getfile = "select imagename, character characterimage imagename='" + similarityimages[0].destination.tostring() + "'";                 sqlcommand cmd2 = new sqlcommand(getfile, con);                 sqldatareader rd2 = cmd2.executereader();                  while (rd2.read())                 {                     (int = 0; < 1; i++)                     {                         string gettext = rd2["character"].tostring();                         action showtext = () => ocrtb.appendtext(gettext);                         ocrtb.invoke(showtext);                     }                 }                 con.close();             }             else             {                 messagebox.show("no character found!", "error!", messageboxbuttons.ok, messageboxicon.error);             }           } 

how move line of code delete file end of process images method?


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -