后台线程和三层架构

时间:2014-01-12 18:54:57

标签: c# multithreading

这是我的Logic_Layer,我想向GUI_Layer发送一个具有某些值,名称,电话,类型和结果的特定日期,其中必须通过后台工作人员在消息框中显示它。 问题是我的logic_layer没有在List中获取任何信息。怎么解决这个问题?

List<Test_DTO> pReminder = new List<Test_DTO>();

public List<Person_DTO> Reminder(string name, string phone, string type, string resul)
{
    GetPersonFromDataLayer();
    foreach (Person_DTO person in personList)
    {
        foreach (Test_DTO test in person.TestListe)
        {
            if (DateTime.Parse(pr.ContactTime).Date == DateTime.Now.Date)
            {
                if (!pReminder.Contains(test))
                {
                    pReminder.Add(test);
                }
                personDTO.TestList = pReminder;
                personList.Add(personDTO);
            }
        }
    }
    return persList;
}

这是GUI层。

private void System_Load(object sender, EventArgs e)
{
    string name = null;
    string phone = null;
    string type = null;
    string result = null;

    reminderThread = new Thread(() => logik.Reminder(name, phone, type, result));
    Reminder(name, phone, type, result);
    reminderThread.IsBackground = true;
    reminderThread.Start();
}

public void Reminder(string name, string phone, string type, string result)
{
    personList = logik.Reminder(name, phone, type, result);
    {
        MessageBox.Show("Reminder!\nContact: " + navn + "\nPhone number: "
        + telefonnummer + "\n___________________________\nTest type: " + type + "\nResult: " + resultat);
        Thread.Sleep(1000);
    }
    Thread.Sleep(10000);
}

0 个答案:

没有答案