CÁC GIẢI PHÁP LẬP TRÌNH C# - Trang 337

337

Chương 8: Đồ họa, đa phương tiện, và in ấn

}

}

private void cmdResume_Click(object sender, System.EventArgs e) {

if (lstJobs.SelectedIndex == -1) return;

ManagementObject job = GetSelectedJob();

if (job == null) return;

if ((Int32.Parse(job["StatusMask"].ToString()) & 1) == 1) {

// Phục hồi tác vụ.

int returnValue = Int32.Parse(

job.InvokeMethod("Resume", null).ToString());

// Hiển thị thông tin về giá trị trả về.

if (returnValue == 0) {

MessageBox.Show("Successfully resumed job.");

}else if (returnValue == 5) {

MessageBox.Show("Access denied.");

}else {

MessageBox.Show(

"Unrecognized return value when resuming job.");

}

}

}

}