/// <summary> /// Queue job data /// </summary> /// <param name="jobData">Job data</param> public void QueueJobData(TruckingVSAPIJobData jobData) { if (jobData != null) { lock (jobDataQueue) { jobDataQueue.Enqueue(jobData); } } }
/// <summary> /// Constructor /// </summary> /// <param name="userID">User ID</param> /// <param name="userCompanyID">User company ID</param> /// <param name="authCode">Auth codee</param> /// <param name="username">Username</param> /// <param name="gravatarURI">Gravatar URL</param> private TruckingVSAPI(int userID, int userCompanyID, string authCode, string username, Uri gravatarURI) { this.userID = userID; this.userCompanyID = userCompanyID; this.authCode = authCode; this.username = username; this.gravatarURI = gravatarURI; jobDataThread = new Thread(() => { while (isJobDataThreadRunning) { lock (jobDataQueue) { while (jobDataQueue.Count > 0) { TruckingVSAPIJobData job_data = jobDataQueue.Dequeue(); switch (job_data.Type) { case ETruckingVSAPIJobDataType.New: NewJob(job_data.TelemetryData); break; case ETruckingVSAPIJobDataType.DataUpdated: UpdateJobData(job_data.TelemetryData); break; case ETruckingVSAPIJobDataType.Finished: FinishJob(job_data.TelemetryData); break; case ETruckingVSAPIJobDataType.Canceled: CancelJob(); break; } } } Thread.Sleep(500); } }); jobDataThread.Start(); }