Good afternoon,
I'm trying to fire an ICommand in the viewmodel... FROM the viewmodel, instead of from the UI.
The command works fine from the UI xaml, however, in this different scenario, it does not.
private DispatcherTimer telTimer;
public RelayCommand StartT_Command { get { return new RelayCommand(Exe_StartT_Command); } }
void Exe_StartT_Command(object parameter)
{
if (telTimer != null && telTimer.IsEnabled)
{
telTimer.Stop();
return;
}
telTimer = new DispatcherTimer();
telTimer.Tick += new EventHandler(TelTimerTick);
telTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);
telTimer.Start();
}
private void TelTimerTick(object sender, EventArgs e) //Every Tick
{
Data.Te(Td);
}
Like I said, it runs fine from the UI, however, when called (see below) it runs all the way through telTimer.Start(); and then ... doesn't.
void KeyDown(int vKey)
{
if (vKey == 0x6A) //Num Pad * Key
{
this.StartT_Command.Execute(null);
}
}
Any ideas??
Thanks in advance.
EDIT1: I checked .IsEnabled, and the timer IS enabled. However, TelTimerTick() is not running.
EDIT2: I didn't mention that KeyDown is being called from different Thread. Would that have an affect on the event hitting TelTimerTick()?