I am trying to show the count in a label based on the time using timespan
but label always null
while i am debugging the code there are showing the count value in the label but not on the browser
- public partial class _Default : System.Web.UI.Page
- {
- public int j;
- public int numoffers = 6000;
- public int i;
- protected void Page_Load(object sender, EventArgs e)
- {
- SetInterval(() => calculate(), TimeSpan.FromSeconds(10));
- }
- public void calculate()
- {
- DateTime time = DateTime.Now;
- int hour = time.Hour;
- int minute = time.Minute;
- int second = time.Second;
- int numofdays = 90;
- int num = Check_Prime(minute);
- int numofperday = numoffers / numofdays;
- if (minute % 2 == 0)
- {
- j = j + 2;
- i = numoffers - j;
- }
- else
- {
- if (num == 1)
- {
- j = j + 3;
- i = numoffers - j;
- }
- else
- {
- j = j + 5;
- i = numoffers - j;
- }
- }
- if (j >=6000)
- {
- Thread.Sleep(TimeSpan.FromSeconds(100000));
- }
- Label2.Text = i.ToString();
- }
- public async Task SetInterval(Action action, TimeSpan timeout)
- {
- await Task.Delay(timeout).ConfigureAwait(false);
- action();
- SetInterval(action, timeout);
- }
- private int Check_Prime(int number)
- {
- int i;
- for (i = 2; i <= number - 1; i++)
- {
- if (number % i == 0)
- {
- return 0;
- }
- }
- if (i == number)
- {
- return 1;
- }
- return 0;
- }
- }