SHARE
TWEET

Untitled

a guest Feb 24th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. consolemessage("STARTUP", "Verifying existence of essential files...");
  2. if(!File.Exists("Interop.NATUPNPLib.dll"))
  3.     Download("link here", "Interop.NATUPNPLib.dll");
  4. if(!File.Exists("LICENSE.txt"))
  5.     Download("link here", "LICENSE.txt");
  6. consolemessage("STARTUP", "Essential file validation completed!");
  7.    
  8. public partial class MainWindow : Window
  9. {
  10.     private BackgroundWorker worker;
  11.  
  12.     public MainWindow()
  13.     {
  14.         InitializeComponent();
  15.  
  16.         Loaded += MainWindow_Loaded;
  17.     }
  18.  
  19.     void MainWindow_Loaded(object sender, RoutedEventArgs e)
  20.     {
  21.         worker = new BackgroundWorker();
  22.         worker.DoWork += worker_DoWork;
  23.         worker.RunWorkerCompleted += worker_RunWorkerCompleted;
  24.         worker.RunWorkerAsync();
  25.         consolemessage("STARTUP", "Verifying existence of essential files...");
  26.     }
  27.  
  28.     void worker_DoWork(object sender, DoWorkEventArgs e)
  29.     {
  30.         if (!File.Exists("Interop.NATUPNPLib.dll"))
  31.             Download("link here", "Interop.NATUPNPLib.dll");
  32.  
  33.         if (!File.Exists("LICENSE.txt"))
  34.             Download("link here", "LICENSE.txt");
  35.     }
  36.  
  37.     void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
  38.     {
  39.         // Signal your UI that the files are now available here if needed.
  40.         consolemessage("STARTUP", "Essential file validation completed!");
  41.     }
  42. }
  43.    
  44. using System.Threading;
  45.    
  46. private void Window_Loaded(object sender, RoutedEventArgs e)
  47. {
  48.     Thread t = new Thread( YourMethod);
  49.     t.IsBackground = true;
  50.     t.Start();
  51. }
  52. void YourMethod()
  53. {
  54.     consolemessage("STARTUP", "Verifying existence of essential files...");
  55.     if (!File.Exists("Interop.NATUPNPLib.dll"))
  56.         Download("link here", "Interop.NATUPNPLib.dll");
  57.     if (!File.Exists("LICENSE.txt"))
  58.         Download("link here", "LICENSE.txt");
  59.     consolemessage("STARTUP", "Essential file validation completed!");
  60. }
  61.    
  62. public partial class MainWindow : Window
  63. {
  64.     System.Windows.Threading.DispatcherTimer oneShot = new System.Windows.Threading.DispatcherTimer();
  65.     public MainWindow()
  66.     {
  67.         InitializeComponent();
  68.         oneShot.Interval = new TimeSpan(0, 0, 0, 0, 100);
  69.         oneShot.Tick += new EventHandler(oneShot_Tick);
  70.     }
  71.  
  72.     void oneShot_Tick(object sender, EventArgs e)
  73.     {
  74.         oneShot.Stop();
  75.  
  76.         // Your Code or Method here
  77.     }
  78.  
  79.     private void Window_Loaded(object sender, RoutedEventArgs e)
  80.     {
  81.         oneShot.Start();
  82.     }
  83. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top