Making API call every 5 seconds in C#











up vote
0
down vote

favorite












I'm trying to develop a mobile app on Xamarin Forms platform.I'm getting data from API.API call only happened once only when the application is opened. I'm Listing livescores between teams in a ListView . For example the minutes of the match 25 for now.I'm waiting 2 minutes and nothing changed. The minute is the same on my ListView.When I close and open the app again minute is changing.I just want to make call every 5 second to refresh the data without close the application.
Here is my code.



public List<liveScoreData>liveScore() 
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);

using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;

var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);


var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());

Mehmet.liveScoreDataList = result;

}
}
catch (Exception ex)
{
var exc = ex;
}

return result;

}









share|improve this question




















  • 1




    Why do you get a string, deserialize to object, turn it back to a string, and then deserialize it again?
    – Jamiec
    Nov 19 at 12:49

















up vote
0
down vote

favorite












I'm trying to develop a mobile app on Xamarin Forms platform.I'm getting data from API.API call only happened once only when the application is opened. I'm Listing livescores between teams in a ListView . For example the minutes of the match 25 for now.I'm waiting 2 minutes and nothing changed. The minute is the same on my ListView.When I close and open the app again minute is changing.I just want to make call every 5 second to refresh the data without close the application.
Here is my code.



public List<liveScoreData>liveScore() 
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);

using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;

var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);


var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());

Mehmet.liveScoreDataList = result;

}
}
catch (Exception ex)
{
var exc = ex;
}

return result;

}









share|improve this question




















  • 1




    Why do you get a string, deserialize to object, turn it back to a string, and then deserialize it again?
    – Jamiec
    Nov 19 at 12:49















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to develop a mobile app on Xamarin Forms platform.I'm getting data from API.API call only happened once only when the application is opened. I'm Listing livescores between teams in a ListView . For example the minutes of the match 25 for now.I'm waiting 2 minutes and nothing changed. The minute is the same on my ListView.When I close and open the app again minute is changing.I just want to make call every 5 second to refresh the data without close the application.
Here is my code.



public List<liveScoreData>liveScore() 
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);

using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;

var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);


var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());

Mehmet.liveScoreDataList = result;

}
}
catch (Exception ex)
{
var exc = ex;
}

return result;

}









share|improve this question















I'm trying to develop a mobile app on Xamarin Forms platform.I'm getting data from API.API call only happened once only when the application is opened. I'm Listing livescores between teams in a ListView . For example the minutes of the match 25 for now.I'm waiting 2 minutes and nothing changed. The minute is the same on my ListView.When I close and open the app again minute is changing.I just want to make call every 5 second to refresh the data without close the application.
Here is my code.



public List<liveScoreData>liveScore() 
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);

using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;

var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);


var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());

Mehmet.liveScoreDataList = result;

}
}
catch (Exception ex)
{
var exc = ex;
}

return result;

}






c# api xamarin call






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 12:46









Sir Rufo

14.3k22757




14.3k22757










asked Nov 19 at 11:54









İsmail Çapkın

112




112








  • 1




    Why do you get a string, deserialize to object, turn it back to a string, and then deserialize it again?
    – Jamiec
    Nov 19 at 12:49
















  • 1




    Why do you get a string, deserialize to object, turn it back to a string, and then deserialize it again?
    – Jamiec
    Nov 19 at 12:49










1




1




Why do you get a string, deserialize to object, turn it back to a string, and then deserialize it again?
– Jamiec
Nov 19 at 12:49






Why do you get a string, deserialize to object, turn it back to a string, and then deserialize it again?
– Jamiec
Nov 19 at 12:49














2 Answers
2






active

oldest

votes

















up vote
0
down vote













What you can do is implement my special PollingTimer.cs class:



using System;
using System.Threading;
using Xamarin.Forms;

namespace AppNamespace.Helpers
{
/// <summary>
/// This timer is used to poll the middleware for new information.
/// </summary>
public class PollingTimer
{
private readonly TimeSpan timespan;
private readonly Action callback;

private CancellationTokenSource cancellation;

/// <summary>
/// Initializes a new instance of the <see cref="T:CryptoTracker.Helpers.PollingTimer"/> class.
/// </summary>
/// <param name="timespan">The amount of time between each call</param>
/// <param name="callback">The callback procedure.</param>
public PollingTimer(TimeSpan timespan, Action callback)
{
this.timespan = timespan;
this.callback = callback;
this.cancellation = new CancellationTokenSource();
}

/// <summary>
/// Starts the timer.
/// </summary>
public void Start()
{
CancellationTokenSource cts = this.cancellation; // safe copy
Device.StartTimer(this.timespan,
() => {
if (cts.IsCancellationRequested) return false;
this.callback.Invoke();
return true; // or true for periodic behavior
});
}

/// <summary>
/// Stops the timer.
/// </summary>
public void Stop()
{
Interlocked.Exchange(ref this.cancellation, new CancellationTokenSource()).Cancel();
}
}
}


Then what you can do following that is in your page that you want to make a call every 5 seconds from, in the constructor at the end of it you can write this line of code:



timer = new PollingTimer(TimeSpan.FromSeconds(5), liveScore);


This will run your method every 5 seconds. To make your method work with the pollingtimer you must edit your method to a void and return the value to a global variable like so:



//Make a global variable for your method to access
List<liveScoreData> globalLiveScore = new List<liveScoreData>();

public void liveScore()
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);



using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;



var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);



var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());



Mehmet.liveScoreDataList = result;


}
}
catch (Exception ex)
{
var exc = ex;
}


globalLiveScore = result;



}


Then from there you can check your live score data in other methods. Then in your OnAppearing method you can run



timer.Start();


and in your OnDisappearing method you can run



timer.Stop();


have a play with it and see if you can put it in better places for optimal performance etc.






share|improve this answer





















  • You lost my upvote here: ...you must edit your method to a void and return the value to a global variable.... You could improve your PollingTimer hugely by making it generic, representing the return type of the thing its polling over, and supplying a method to call with the result each poll.
    – Jamiec
    Nov 19 at 12:51




















up vote
0
down vote













You could use the System.Threading.Timer object



and simply initialize it like this



`System.Threading.Timer myTimer = new System.Threading.Timer((e) =>
{
liveScore(); //your function call
}, null,
TimeSpan.FromSeconds(0), //start immediately
TimeSpan.FromSeconds(5)); //execute every 5 secs`





share|improve this answer





















  • Thank you for your answer but i tried it didnt work .
    – İsmail Çapkın
    Nov 21 at 6:23











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374096%2fmaking-api-call-every-5-seconds-in-c-sharp%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













What you can do is implement my special PollingTimer.cs class:



using System;
using System.Threading;
using Xamarin.Forms;

namespace AppNamespace.Helpers
{
/// <summary>
/// This timer is used to poll the middleware for new information.
/// </summary>
public class PollingTimer
{
private readonly TimeSpan timespan;
private readonly Action callback;

private CancellationTokenSource cancellation;

/// <summary>
/// Initializes a new instance of the <see cref="T:CryptoTracker.Helpers.PollingTimer"/> class.
/// </summary>
/// <param name="timespan">The amount of time between each call</param>
/// <param name="callback">The callback procedure.</param>
public PollingTimer(TimeSpan timespan, Action callback)
{
this.timespan = timespan;
this.callback = callback;
this.cancellation = new CancellationTokenSource();
}

/// <summary>
/// Starts the timer.
/// </summary>
public void Start()
{
CancellationTokenSource cts = this.cancellation; // safe copy
Device.StartTimer(this.timespan,
() => {
if (cts.IsCancellationRequested) return false;
this.callback.Invoke();
return true; // or true for periodic behavior
});
}

/// <summary>
/// Stops the timer.
/// </summary>
public void Stop()
{
Interlocked.Exchange(ref this.cancellation, new CancellationTokenSource()).Cancel();
}
}
}


Then what you can do following that is in your page that you want to make a call every 5 seconds from, in the constructor at the end of it you can write this line of code:



timer = new PollingTimer(TimeSpan.FromSeconds(5), liveScore);


This will run your method every 5 seconds. To make your method work with the pollingtimer you must edit your method to a void and return the value to a global variable like so:



//Make a global variable for your method to access
List<liveScoreData> globalLiveScore = new List<liveScoreData>();

public void liveScore()
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);



using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;



var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);



var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());



Mehmet.liveScoreDataList = result;


}
}
catch (Exception ex)
{
var exc = ex;
}


globalLiveScore = result;



}


Then from there you can check your live score data in other methods. Then in your OnAppearing method you can run



timer.Start();


and in your OnDisappearing method you can run



timer.Stop();


have a play with it and see if you can put it in better places for optimal performance etc.






share|improve this answer





















  • You lost my upvote here: ...you must edit your method to a void and return the value to a global variable.... You could improve your PollingTimer hugely by making it generic, representing the return type of the thing its polling over, and supplying a method to call with the result each poll.
    – Jamiec
    Nov 19 at 12:51

















up vote
0
down vote













What you can do is implement my special PollingTimer.cs class:



using System;
using System.Threading;
using Xamarin.Forms;

namespace AppNamespace.Helpers
{
/// <summary>
/// This timer is used to poll the middleware for new information.
/// </summary>
public class PollingTimer
{
private readonly TimeSpan timespan;
private readonly Action callback;

private CancellationTokenSource cancellation;

/// <summary>
/// Initializes a new instance of the <see cref="T:CryptoTracker.Helpers.PollingTimer"/> class.
/// </summary>
/// <param name="timespan">The amount of time between each call</param>
/// <param name="callback">The callback procedure.</param>
public PollingTimer(TimeSpan timespan, Action callback)
{
this.timespan = timespan;
this.callback = callback;
this.cancellation = new CancellationTokenSource();
}

/// <summary>
/// Starts the timer.
/// </summary>
public void Start()
{
CancellationTokenSource cts = this.cancellation; // safe copy
Device.StartTimer(this.timespan,
() => {
if (cts.IsCancellationRequested) return false;
this.callback.Invoke();
return true; // or true for periodic behavior
});
}

/// <summary>
/// Stops the timer.
/// </summary>
public void Stop()
{
Interlocked.Exchange(ref this.cancellation, new CancellationTokenSource()).Cancel();
}
}
}


Then what you can do following that is in your page that you want to make a call every 5 seconds from, in the constructor at the end of it you can write this line of code:



timer = new PollingTimer(TimeSpan.FromSeconds(5), liveScore);


This will run your method every 5 seconds. To make your method work with the pollingtimer you must edit your method to a void and return the value to a global variable like so:



//Make a global variable for your method to access
List<liveScoreData> globalLiveScore = new List<liveScoreData>();

public void liveScore()
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);



using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;



var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);



var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());



Mehmet.liveScoreDataList = result;


}
}
catch (Exception ex)
{
var exc = ex;
}


globalLiveScore = result;



}


Then from there you can check your live score data in other methods. Then in your OnAppearing method you can run



timer.Start();


and in your OnDisappearing method you can run



timer.Stop();


have a play with it and see if you can put it in better places for optimal performance etc.






share|improve this answer





















  • You lost my upvote here: ...you must edit your method to a void and return the value to a global variable.... You could improve your PollingTimer hugely by making it generic, representing the return type of the thing its polling over, and supplying a method to call with the result each poll.
    – Jamiec
    Nov 19 at 12:51















up vote
0
down vote










up vote
0
down vote









What you can do is implement my special PollingTimer.cs class:



using System;
using System.Threading;
using Xamarin.Forms;

namespace AppNamespace.Helpers
{
/// <summary>
/// This timer is used to poll the middleware for new information.
/// </summary>
public class PollingTimer
{
private readonly TimeSpan timespan;
private readonly Action callback;

private CancellationTokenSource cancellation;

/// <summary>
/// Initializes a new instance of the <see cref="T:CryptoTracker.Helpers.PollingTimer"/> class.
/// </summary>
/// <param name="timespan">The amount of time between each call</param>
/// <param name="callback">The callback procedure.</param>
public PollingTimer(TimeSpan timespan, Action callback)
{
this.timespan = timespan;
this.callback = callback;
this.cancellation = new CancellationTokenSource();
}

/// <summary>
/// Starts the timer.
/// </summary>
public void Start()
{
CancellationTokenSource cts = this.cancellation; // safe copy
Device.StartTimer(this.timespan,
() => {
if (cts.IsCancellationRequested) return false;
this.callback.Invoke();
return true; // or true for periodic behavior
});
}

/// <summary>
/// Stops the timer.
/// </summary>
public void Stop()
{
Interlocked.Exchange(ref this.cancellation, new CancellationTokenSource()).Cancel();
}
}
}


Then what you can do following that is in your page that you want to make a call every 5 seconds from, in the constructor at the end of it you can write this line of code:



timer = new PollingTimer(TimeSpan.FromSeconds(5), liveScore);


This will run your method every 5 seconds. To make your method work with the pollingtimer you must edit your method to a void and return the value to a global variable like so:



//Make a global variable for your method to access
List<liveScoreData> globalLiveScore = new List<liveScoreData>();

public void liveScore()
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);



using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;



var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);



var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());



Mehmet.liveScoreDataList = result;


}
}
catch (Exception ex)
{
var exc = ex;
}


globalLiveScore = result;



}


Then from there you can check your live score data in other methods. Then in your OnAppearing method you can run



timer.Start();


and in your OnDisappearing method you can run



timer.Stop();


have a play with it and see if you can put it in better places for optimal performance etc.






share|improve this answer












What you can do is implement my special PollingTimer.cs class:



using System;
using System.Threading;
using Xamarin.Forms;

namespace AppNamespace.Helpers
{
/// <summary>
/// This timer is used to poll the middleware for new information.
/// </summary>
public class PollingTimer
{
private readonly TimeSpan timespan;
private readonly Action callback;

private CancellationTokenSource cancellation;

/// <summary>
/// Initializes a new instance of the <see cref="T:CryptoTracker.Helpers.PollingTimer"/> class.
/// </summary>
/// <param name="timespan">The amount of time between each call</param>
/// <param name="callback">The callback procedure.</param>
public PollingTimer(TimeSpan timespan, Action callback)
{
this.timespan = timespan;
this.callback = callback;
this.cancellation = new CancellationTokenSource();
}

/// <summary>
/// Starts the timer.
/// </summary>
public void Start()
{
CancellationTokenSource cts = this.cancellation; // safe copy
Device.StartTimer(this.timespan,
() => {
if (cts.IsCancellationRequested) return false;
this.callback.Invoke();
return true; // or true for periodic behavior
});
}

/// <summary>
/// Stops the timer.
/// </summary>
public void Stop()
{
Interlocked.Exchange(ref this.cancellation, new CancellationTokenSource()).Cancel();
}
}
}


Then what you can do following that is in your page that you want to make a call every 5 seconds from, in the constructor at the end of it you can write this line of code:



timer = new PollingTimer(TimeSpan.FromSeconds(5), liveScore);


This will run your method every 5 seconds. To make your method work with the pollingtimer you must edit your method to a void and return the value to a global variable like so:



//Make a global variable for your method to access
List<liveScoreData> globalLiveScore = new List<liveScoreData>();

public void liveScore()
{
var result = new List<liveScoreData>();
try
{

Guid guidSifre = Guid.NewGuid();
string guid = guidSifre.ToString();
string result = CreateMD5forChecksum(guid);



using (var client = new WebClient())
{
var values = new NameValueCollection();
values["result"] = result;
values["guid"] = guid;



var response = client.UploadValues("http://abcd.com/admin/LiveScore", values);

var responseString = Encoding.Default.GetString(response);



var responseResult = JsonConvert.DeserializeObject(responseString);
result = JsonConvert.DeserializeObject<List<liveScoreData>>(responseResult.ToString());



Mehmet.liveScoreDataList = result;


}
}
catch (Exception ex)
{
var exc = ex;
}


globalLiveScore = result;



}


Then from there you can check your live score data in other methods. Then in your OnAppearing method you can run



timer.Start();


and in your OnDisappearing method you can run



timer.Stop();


have a play with it and see if you can put it in better places for optimal performance etc.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 at 12:32









James Mallon

231110




231110












  • You lost my upvote here: ...you must edit your method to a void and return the value to a global variable.... You could improve your PollingTimer hugely by making it generic, representing the return type of the thing its polling over, and supplying a method to call with the result each poll.
    – Jamiec
    Nov 19 at 12:51




















  • You lost my upvote here: ...you must edit your method to a void and return the value to a global variable.... You could improve your PollingTimer hugely by making it generic, representing the return type of the thing its polling over, and supplying a method to call with the result each poll.
    – Jamiec
    Nov 19 at 12:51


















You lost my upvote here: ...you must edit your method to a void and return the value to a global variable.... You could improve your PollingTimer hugely by making it generic, representing the return type of the thing its polling over, and supplying a method to call with the result each poll.
– Jamiec
Nov 19 at 12:51






You lost my upvote here: ...you must edit your method to a void and return the value to a global variable.... You could improve your PollingTimer hugely by making it generic, representing the return type of the thing its polling over, and supplying a method to call with the result each poll.
– Jamiec
Nov 19 at 12:51














up vote
0
down vote













You could use the System.Threading.Timer object



and simply initialize it like this



`System.Threading.Timer myTimer = new System.Threading.Timer((e) =>
{
liveScore(); //your function call
}, null,
TimeSpan.FromSeconds(0), //start immediately
TimeSpan.FromSeconds(5)); //execute every 5 secs`





share|improve this answer





















  • Thank you for your answer but i tried it didnt work .
    – İsmail Çapkın
    Nov 21 at 6:23















up vote
0
down vote













You could use the System.Threading.Timer object



and simply initialize it like this



`System.Threading.Timer myTimer = new System.Threading.Timer((e) =>
{
liveScore(); //your function call
}, null,
TimeSpan.FromSeconds(0), //start immediately
TimeSpan.FromSeconds(5)); //execute every 5 secs`





share|improve this answer





















  • Thank you for your answer but i tried it didnt work .
    – İsmail Çapkın
    Nov 21 at 6:23













up vote
0
down vote










up vote
0
down vote









You could use the System.Threading.Timer object



and simply initialize it like this



`System.Threading.Timer myTimer = new System.Threading.Timer((e) =>
{
liveScore(); //your function call
}, null,
TimeSpan.FromSeconds(0), //start immediately
TimeSpan.FromSeconds(5)); //execute every 5 secs`





share|improve this answer












You could use the System.Threading.Timer object



and simply initialize it like this



`System.Threading.Timer myTimer = new System.Threading.Timer((e) =>
{
liveScore(); //your function call
}, null,
TimeSpan.FromSeconds(0), //start immediately
TimeSpan.FromSeconds(5)); //execute every 5 secs`






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 19 at 12:56









Madenis

13729




13729












  • Thank you for your answer but i tried it didnt work .
    – İsmail Çapkın
    Nov 21 at 6:23


















  • Thank you for your answer but i tried it didnt work .
    – İsmail Çapkın
    Nov 21 at 6:23
















Thank you for your answer but i tried it didnt work .
– İsmail Çapkın
Nov 21 at 6:23




Thank you for your answer but i tried it didnt work .
– İsmail Çapkın
Nov 21 at 6:23


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374096%2fmaking-api-call-every-5-seconds-in-c-sharp%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

Origin of the phrase “under your belt”?