Create a Modeless Messagebox

后端 未结 7 1478
难免孤独
难免孤独 2021-02-07 01:00

How might one go about creating a Modeless MessageBox? Do I have to just create my own Windows Form class and use that? If so, is there an easy way of adding a warning icon (rat

7条回答
  •  难免孤独
    2021-02-07 01:32

    //no commnet

    object sync = new object();
    ManualResetEvent Wait = new ManualResetEvent();
    //you should create a place holder named MessageData for Message Data.
    List Messages = new List();
    internal void ShowMessage(string Test, string Title, ....)
    {
        MessageData MSG = new MessageData(Test, Title);
        Wait.Set();
        lock(sync) Messages.Add(MSG);
    }
    // another thread should run here.
    void Private_Show()
    {
        while(true)
    {
            while(Messsages.Count != 0)
            {
                MessageData md;
                lock(sync)
                {
                    md = List[0];
                    List.RemoveAt(0);
                }
                MessageBox.Show(md.Text, md.Title, md....);
            }
            Wait.WaitOne();
        }
    }
    

    needs more threads and more code(I don't have enough time to write) for concurrent messageboxes.

提交回复
热议问题