问题
I'm new to this type of programming (management figures programming is programming... ugh), apologies in advance if my question seems convoluted or basic.
I'm creating a Windows Form App in Visual Studio 2015. I have it communicating and sharing with our SQL Server perfectly for every function but one. I'd like to place a "live" counter on the form, that updates a value every 3(or something) seconds. The counter's job would be to keep track of inventory being shipped out of our warehouse (just need to worry about getting that info from our SQL Server, which already has the capabilities, nothing before that) and display that information. Doesn't have to fancy, just accurate.
I've tried searching for answers for a while, but I'm not sure I'm using the right terms or maybe I've overlooked what I should be using for this process. I'm not looking for a complete solution, just a link to a site or some terminology help that describes what I need would be truly appreciated.
Thanks in advance everyone.
回答1:
Try following to run code every interval
millisecond.
public static void InitializeTimer()
{
var inerval = 3000;
var timer = new System.Timers.Timer();
timer.Elapsed += keep_track_of_inventory_being_shipped;
timer.Interval = inerval;
timer.Start();
}
private static void keep_track_of_inventory_being_shipped(object sender, System.Timers.ElapsedEventArgs e)
{
//your code here
}
来源:https://stackoverflow.com/questions/34701204/dynamic-item-counter-from-sqlserver-2014-in-web-form-for-visual-studio-2015