나는 키 넥트와 WPF 응용 프로그램을 작성하려고, 그래서 나는이 코드를 쓰기가 :대리인 BackgroundWorker를 사용하는 방법?
[System.InvalidOperationException] = {"The calling thread cannot access this object because a different thread owns it."}"
:이 코드 this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
, 내가 가진이 오류를 실행하려고 할 때 그래서
static BackgroundWorker _bw = new BackgroundWorker();
_bw.DoWork += bw_DoWork;
_bw.RunWorkerAsync();
dispatcherTimerGame = new System.Windows.Threading.DispatcherTimer();
dispatcherTimerGame.Tick += new EventHandler(dispatcher_VerificaCarte);
dispatcherTimerGame.Interval = new TimeSpan(0, 0, 1);
dispatcherTimerGame.Start();
void bw_DoWork(object sender, DoWorkEventArgs e)
{
try
{
this.sensorChooser = new KinectSensorChooser();
this.sensorChooser.KinectChanged += SensorChooserOnKinectChanged;
this.sensorChooserUi.KinectSensorChooser = this.sensorChooser;
this.sensorChooser.Start();
this.sensor = this.sensorChooser.Kinect;
if (this.sensor != null)
{
DateTime dat1 = DateTime.Now;
string date = DateTime.Now.ToString("dd-MMM-yy HH-mm");
acquisizioneVideo = new Acquisizione("Video" + date + ".avi");
this.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
acquisizioneAudio = new AcquisizioneWaveAudio(180, this.sensor, "Audio" + date + ".wav"); acquisizioneAudio.recordAudio();
acquisizioneVideo.recordVideo();
this.sensor.ColorFrameReady += acquisizioneVideo.ColorImageReady;
}
}
catch (Exception exc)
{
log.Error(exc);
}
}
을 어떻게 해결할 수 있습니까?
감사합니다.하지만 Kinect가 초기화 될 때 다른 코드를 실행하고 싶기 때문에 BackgroundWorker를 사용했습니다. main 메소드에서이 코드를 작성하면 AsyncTask가 없습니다 – bircastri
가능하면 다른 비동기 코드를 실행할 수 있습니다. – pushpraj