Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- consolemessage("STARTUP", "Verifying existence of essential files...");
- if(!File.Exists("Interop.NATUPNPLib.dll"))
- Download("link here", "Interop.NATUPNPLib.dll");
- if(!File.Exists("LICENSE.txt"))
- Download("link here", "LICENSE.txt");
- consolemessage("STARTUP", "Essential file validation completed!");
- public partial class MainWindow : Window
- {
- private BackgroundWorker worker;
- public MainWindow()
- {
- InitializeComponent();
- Loaded += MainWindow_Loaded;
- }
- void MainWindow_Loaded(object sender, RoutedEventArgs e)
- {
- worker = new BackgroundWorker();
- worker.DoWork += worker_DoWork;
- worker.RunWorkerCompleted += worker_RunWorkerCompleted;
- worker.RunWorkerAsync();
- consolemessage("STARTUP", "Verifying existence of essential files...");
- }
- void worker_DoWork(object sender, DoWorkEventArgs e)
- {
- if (!File.Exists("Interop.NATUPNPLib.dll"))
- Download("link here", "Interop.NATUPNPLib.dll");
- if (!File.Exists("LICENSE.txt"))
- Download("link here", "LICENSE.txt");
- }
- void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
- {
- // Signal your UI that the files are now available here if needed.
- consolemessage("STARTUP", "Essential file validation completed!");
- }
- }
- using System.Threading;
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- Thread t = new Thread( YourMethod);
- t.IsBackground = true;
- t.Start();
- }
- void YourMethod()
- {
- consolemessage("STARTUP", "Verifying existence of essential files...");
- if (!File.Exists("Interop.NATUPNPLib.dll"))
- Download("link here", "Interop.NATUPNPLib.dll");
- if (!File.Exists("LICENSE.txt"))
- Download("link here", "LICENSE.txt");
- consolemessage("STARTUP", "Essential file validation completed!");
- }
- public partial class MainWindow : Window
- {
- System.Windows.Threading.DispatcherTimer oneShot = new System.Windows.Threading.DispatcherTimer();
- public MainWindow()
- {
- InitializeComponent();
- oneShot.Interval = new TimeSpan(0, 0, 0, 0, 100);
- oneShot.Tick += new EventHandler(oneShot_Tick);
- }
- void oneShot_Tick(object sender, EventArgs e)
- {
- oneShot.Stop();
- // Your Code or Method here
- }
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- oneShot.Start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement