Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.ServiceModel;
- using System.Text;
- using System.Threading;
- namespace WcfServiceLibrary2
- {
- // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
- [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
- public class myCallbackKalkulator : ICallbackKalkulator
- {
- private int result;
- private double coeff;
- private ICallbackHandler callback = null;
- public myCallbackKalkulator()
- {
- callback = OperationContext.Current.GetCallbackChannel<ICallbackHandler>();
- }
- public void Function1(int n)
- {
- Console.WriteLine("...call of Function1({0})", n);
- long maxN = 1;
- for (int i = 1; i <= n; ++i)
- {
- bool isPrime = true;
- for (int j = 2; j < Math.Sqrt(i); ++j)
- {
- if (i % j == 0)
- {
- isPrime = false;
- break;
- }
- }
- if (isPrime)
- {
- maxN = i;
- }
- }
- callback.Function1CB(maxN);
- }
- public void Function2(int n, int k)
- {
- Console.WriteLine("...call of Function2({0}, {1})", n, k);
- coeff = (factorial(n) / (factorial(k) * factorial(n - k)));
- callback.Function2CB(coeff);
- }
- private double factorial(int n)
- {
- result = 1;
- for (int i = 1; i <= n; i++)
- {
- result *= i;
- }
- return result;
- }
- }
- }
Add Comment
Please, Sign In to add comment