Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Runtime.Remoting.Messaging;
- namespace opi_lab2
- {
- public delegate double DoOperation(double a, double b);
- public class Solver
- {
- public static double DoCalc(double x)
- {
- double res = Math.Sqrt(6.0 * Math.Pow(x, 2) - 1);
- if (double.IsNaN(res))
- {
- return 0;
- }
- else return res;
- }
- public double Calculate(double a, double b)
- {
- double res = 0;
- for (double x = a; x <= b; x += 0.01)
- {
- res += DoCalc(x);
- }
- return res;
- }
- public static void CallBack(IAsyncResult ires)
- {
- AsyncResult ares = (AsyncResult)ires;
- DoOperation del = (DoOperation)(ares.AsyncDelegate);
- Form1 myForm = (Form1)ares.AsyncState;
- double result = del.EndInvoke(ires);
- myForm.textBoxRes.Invoke(new Action(
- () =>
- {
- myForm.textBoxRes.Text = result.ToString();
- myForm.buttonStart.Enabled = true;
- }));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement