Guest User

Untitled

a guest
Dec 13th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. public partial class Form1 : Form
  2. {
  3.  
  4. static AutoResetEvent autoResetEvent = new AutoResetEvent(false);
  5.  
  6.  
  7. public Form1()
  8. {
  9. InitializeComponent();
  10.  
  11. Task task = Task.Factory.StartNew(() =>
  12. {
  13. button1_Click();
  14. });
  15. autoResetEvent.WaitOne();
  16.  
  17. if (excelValues != null)
  18. {
  19. string dayOne = excelValues.workoutOfTheDay[0].name;
  20. MessageBox.Show(dayOne);
  21. }
  22. else
  23. {
  24. MessageBox.Show("No excel values");
  25. }
  26.  
  27. }
  28.  
  29. public event EventHandler FileCreated;
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36. public string FileName { get; set; }
  37.  
  38. public day excelValues { get; set; }
  39.  
  40.  
  41.  
  42. private void button1_Click(object sender, EventArgs e)
  43. {
  44. OpenFileDialog filepath = new OpenFileDialog();
  45. string FileNameOld = string.Empty;
  46. if (filepath.ShowDialog() == DialogResult.OK)
  47. {
  48. FileNameOld = filepath.FileName;
  49. //MessageBox.Show(FileName);
  50. this.FileName = FileNameOld;
  51. // MessageBox.Show(FileName);
  52.  
  53. excelParser.Program newclass = new excelParser.Program();
  54. this.excelValues = newclass.ExcelExecute(FileName);
  55.  
  56. autoResetEvent.Set();
  57. // var numberOfLines = excelValues.workoutOfTheDay.Count;
  58.  
  59. }
  60. else
  61. {
  62. MessageBox.Show("You need to select a file");
  63.  
  64. }
  65.  
  66. }
  67.  
  68. private void webBrowser1_DocumentCompleted(object sender,
  69. WebBrowserDocumentCompletedEventArgs e)
  70. {
  71.  
  72. }
  73. }
Add Comment
Please, Sign In to add comment