Hi,
I can't update a text box via a timer.
This is the declaration of the texbox and the property
<TextBlock Text="{Binding RowsImport, Mode=TwoWay}"/>
private string _RowsImport;
public string RowsImport
{
get { return _RowsImport; }
set
{
_RowsImport = value;
base.OnPropertyChanged("RowsImport");
}
}
And this is the timer.
System.Timers.Timer timer = new System.Timers.Timer(1000);
timer.AutoReset = true;
timer.Elapsed += TimerCallback;
timer.Start();
using (TransactionScope ts = new TransactionScope())
{
importResult = _dsMain.ImportData_RIL();
if (importResult)
ts.Complete();
}
timer.Stop();
And the procedure
void TimerCallback(object sender, EventArgs e)
{
RowsImport= UTILITY.General.PARAM_PROG_RIL_COUNT;
OnPropertyChanged("RowsImport");
}
Unfortunately this code doesn't work and the textbox never updates !! :-(
p.s.
this is the declaration of
public static string PARAM_PROG_RIL_COUNT { get; set; }
What I have tried:
In the
TimerCallback
I tried to substitude this code
RowsImport= UTILITY.General.PARAM_PROG_RIL_COUNT.ToString();
OnPropertyChanged("RowsImport");
with.....
1 try
Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Background,
new Action(() => RowsImport = UTILITY.General.PARAM_PROG_RIL_COUNT;)));
2 try
Application.Current.Dispatcher.Invoke(
ispatcherPriority.Background,
new Action(() => RowsImport = UTILITY.General.PARAM_PROG_RIL_COUNT
OnPropertyChanged("RowsImport")));
3 try
Application.Current.Dispatcher.Invoke(() =>
RowsImport = UTILITY.General.PARAM_PROG_RIL_COUNT);
4 try
Application.Current.Dispatcher.BeginInvoke(
DispatcherPriority.Background,
new Action(() => {this.RowsImport = UTILITY.General.PARAM_PROG_RIL_COUNT;}));
5 try
Application.Current.Dispatcher.BeginInvoke(new Action(() => this.RowsImport =
UTILITY.General.PARAM_PROG_RIL_COUNT),
System.Windows.Threading.DispatcherPriority.Background, null);
Thread.Sleep(200);
6 try
Application.Current.Dispatcher.BeginInvoke(new Action(() => RowsImport =
UTILITY.General.PARAM_PROG_RIL_COUNT)
System.Windows.Threading.DispatcherPriority.Background, null);
Thread.Sleep(200);
7 try
Application.Current.Dispatcher.Invoke(() =>
{
RowsImport= UTILITY.General.PARAM_PROG_RIL_COUNT;
});
But nothing to do.. ! Doesn't work....
How can I resolve ??
Thanks to everyone who will help me.