Articles → LIGHT SWITCH 2011 → Autorefresh Lightswitch Screen In Lightswitch 2011
Autorefresh Lightswitch Screen In Lightswitch 2011
Software Requirement
- Visual studio 2010 is installed on your machine.
- Visual Studio 2010 service pack 1 is installed on your machine.
- Microsoft Visual Studio Light switch 2011 is installed on your machine.
Prerequisite Knowledge
- What is lightswitch?
- What are screens and entities in lightswitch?
- How to create an entity in lightswitch?
- How to create screens in lightswitch?
Creation Of New Project
Click to Enlarge
Add Employee Entity In The Project
Click to Enlarge
Add Editable Grid Screen
Click to Enlarge
Add Records In The Table
Click to Enlarge
Add Timer In The Screen
using System;
using System.Collections.Generic;
using Microsoft.LightSwitch;
using System.Windows.Threading;
using Microsoft.LightSwitch.Threading;
namespace LightSwitchApplication {
public partial class EditableEmployeesSetGrid {
partial void EditableEmployeesSetGrid_InitializeDataWorkspace(List < IDataService > saveChangesTo) {
Dispatchers.Main.BeginInvoke(() = >{
Timer.Tick += new EventHandler(Each_Tick);
Timer.Start();
});
}
private static readonly DispatcherTimer Timer = new DispatcherTimer() {
Interval = TimeSpan.FromSeconds(5) // Create a timer to refresh screen
};
private void Each_Tick(object sender, EventArgs e) {
Dispatchers.Main.BeginInvoke(() = >{
EmployeesSet.Refresh();
});
}
}
}