c# - Timer Elapsed Event with Kinect SDK -


so i'm using kinect sdk make application, , it's going well! i'm trying make button take picture, want code taking picture delayed people have time pose. i've tried using system.threading.thread.sleep(3000); happens whole thing freezes (yes know that's sleep does...) , uses first frame anyway. i'm trying use timer , timed event, keep getting errors due inability make static (kinect thing).

public class timer1 {     private system.timers.timer atimer;      public void main()     {         atimer = new system.timers.timer(3000);         //this problem is. i'm getting "cannot access non-static member of outer type 'kinectbutton.mainwindow' via nested type 'kinectbutton.mainwindow.timer1'         atimer.elapsed += new elapsedeventhandler(takepicture);         atimer.interval = 1000;         atimer.enabled = true;     } }  [private void takepicture(object sender, elapsedeventargs e) {     bitmapsource image = (bitmapsource)videostream.source;      image.save(datetime.now.tostring("ddmmyyyy hhmmss") + ".jpg", imageformat.jpeg); }  private void button7_click(object sender, routedeventargs e) {     //here i'm getting "'kinectbutton.mainwindow.timer1' not contain definition 'enabled'"     timer1.enabled = true; }  private void timer1_tick(object sender, eventargs e) {     //here i'm getting "'kinectbutton.mainwindow.timer1' not contain definition 'enabled'" again...     timer1.enabled = false; } 

well, let me know if guys can help!

i assume wpf app? think want use windows.threading.dispatchertimer instead

private timer new windows.threading.dispatchertimer  timer.interval = new timespan(0, 0, 0, 1) addhandler timer.tick, addressof timer_tick timer.start()  private sub timer_tick(byval sender object, byval e eventargs)     'do end sub 

yeah know vb should easy convert


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -