Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Runtime.Remoting.Messaging;
  7.  
  8. namespace opi_lab2
  9. {
  10. public delegate double DoOperation(double a, double b);
  11. public class Solver
  12. {
  13. public static double DoCalc(double x)
  14. {
  15. double res = Math.Sqrt(6.0 * Math.Pow(x, 2) - 1);
  16. if (double.IsNaN(res))
  17. {
  18. return 0;
  19. }
  20. else return res;
  21. }
  22.  
  23. public double Calculate(double a, double b)
  24. {
  25. double res = 0;
  26. for (double x = a; x <= b; x += 0.01)
  27. {
  28. res += DoCalc(x);
  29. }
  30. return res;
  31. }
  32.  
  33. public static void CallBack(IAsyncResult ires)
  34. {
  35. AsyncResult ares = (AsyncResult)ires;
  36. DoOperation del = (DoOperation)(ares.AsyncDelegate);
  37. Form1 myForm = (Form1)ares.AsyncState;
  38. double result = del.EndInvoke(ires);
  39. myForm.textBoxRes.Invoke(new Action(
  40. () =>
  41. {
  42. myForm.textBoxRes.Text = result.ToString();
  43. myForm.buttonStart.Enabled = true;
  44. }));
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement