Click here to Skip to main content
15,911,762 members
Home / Discussions / C#
   

C#

 
QuestionSetting a default value for a datagridviewtextbox column Pin
bluewavestrider13-Jan-07 12:07
bluewavestrider13-Jan-07 12:07 
AnswerRe: Setting a default value for a datagridviewtextbox column Pin
Lisa Jorgensen13-Jan-07 15:14
Lisa Jorgensen13-Jan-07 15:14 
GeneralRe: Setting a default value for a datagridviewtextbox column Pin
bluewavestrider14-Jan-07 4:45
bluewavestrider14-Jan-07 4:45 
Questionhow to read status registers of parallel port Pin
George-Lucian13-Jan-07 11:44
George-Lucian13-Jan-07 11:44 
AnswerRe: how to read status registers of parallel port Pin
Phillip M. Hoff13-Jan-07 11:59
Phillip M. Hoff13-Jan-07 11:59 
QuestionA multithreading "best practice" question! Pin
Nader Elshehabi13-Jan-07 10:58
Nader Elshehabi13-Jan-07 10:58 
AnswerRe: A multithreading "best practice" question! Pin
Phillip M. Hoff13-Jan-07 11:38
Phillip M. Hoff13-Jan-07 11:38 
GeneralRe: A multithreading "best practice" question! Pin
Nader Elshehabi13-Jan-07 12:28
Nader Elshehabi13-Jan-07 12:28 
Thanks for your very valuable help. I really appreciate it.
Actually about the "impatient user multiple-click" issue. The list is updated by several events, so I can't really have control on the refreshing. I need that when the user triggers an event that requires refreshment that the current thread is gracefully terminated, and a new thread started again.
I've made a few adjustment to the code. Now My main thread freezes even though I use BeginInvoke(). Any idea way.
internal void PopulateList()
        {
            /*if (!IsPopulating && StopPopulating)
                return;
            IsPopulating = false;
            StopPopulating = true;
            while (Populator != null && Populator.IsAlive)
                Application.DoEvents();*/
            Populator = new Thread(new ThreadStart(PopulateMethod));
            Populator.IsBackground = true;
            Populator.Priority = ThreadPriority.BelowNormal;
            IsPopulating = true;
            StopPopulating = false;
            Populator.Start();
        }

        private void PopulateMethod()
        {
            lock ("Populating")
            {
                try
                {
                    CathProxy PatientsProxy = (CathProxy)Activator.GetObject(typeof(CathProxy), CathLab.Url);
                    DataTable mvps = new DataTable();
                    DataTable Pts = PatientsProxy.GetList(out mvps);
                    updateDel update = new updateDel(UpdateList);
                    this.BeginInvoke(update, new object[] { Pts, mvps });
                }
                catch (SystemException ex)
                {
                    MessageBox.Show(ex.Message, "Error populating patients list");
                }
            }
        }

        private void UpdateList(DataTable Pts, DataTable mvps)
        {
            Patients.Nodes.Clear();
            TreeNode PleaseWait = Patients.Nodes.Add("Refreshing list. Please Wait");
            Patients.BeginUpdate();
            foreach (DataRow r in Pts.Rows)
            {
                if (StopPopulating)
                    return;
                TreeNode CurrentNode = Patients.Nodes.Add('(' + r["Hospital_Number"].ToString() + ") " + r["Patient_Name"].ToString());

                foreach (DataRow ro in mvps.Rows)
                {
                    if (r["Hospital_Number"].ToString() == ro["Hospital_Number"].ToString())
                        CurrentNode.Nodes.Add("MVP at " + DateTime.Parse(ro["Procedure_Date"].ToString()).ToShortDateString());
                }
            }
            PleaseWait.Remove();
            Patients.EndUpdate();
            IsPopulating = false;
            StopPopulating = false;
        }


Thanks again for your time.

RegardsRose | [Rose]

GeneralRe: A multithreading "best practice" question! Pin
Phillip M. Hoff13-Jan-07 14:25
Phillip M. Hoff13-Jan-07 14:25 
GeneralRe: A multithreading "best practice" question! Pin
Nader Elshehabi14-Jan-07 9:02
Nader Elshehabi14-Jan-07 9:02 
QuestionXNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Software_Specialist13-Jan-07 10:48
Software_Specialist13-Jan-07 10:48 
AnswerRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Nader Elshehabi13-Jan-07 11:12
Nader Elshehabi13-Jan-07 11:12 
GeneralRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Software_Specialist13-Jan-07 11:31
Software_Specialist13-Jan-07 11:31 
GeneralRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Nader Elshehabi13-Jan-07 12:05
Nader Elshehabi13-Jan-07 12:05 
AnswerRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Colin Angus Mackay13-Jan-07 11:39
Colin Angus Mackay13-Jan-07 11:39 
GeneralRe: XNA requirement or Direct x 9 works fine with C#...or OpenGL Pin
Software_Specialist13-Jan-07 12:07
Software_Specialist13-Jan-07 12:07 
QuestionRead Excel file and create another file met some part of first excel file [modified] Pin
teymur_khan13-Jan-07 10:05
teymur_khan13-Jan-07 10:05 
AnswerRe: Read Excel file and create another file met some part of first excel file Pin
Phillip M. Hoff13-Jan-07 11:50
Phillip M. Hoff13-Jan-07 11:50 
GeneralRe: Read Excel file and create another file met some part of first excel file Pin
teymur_khan14-Jan-07 5:14
teymur_khan14-Jan-07 5:14 
Questionhow to manage Device(s) from USB port ? Pin
hdv21213-Jan-07 9:28
hdv21213-Jan-07 9:28 
AnswerRe: how to manage Device(s) from USB port ? Pin
Nader Elshehabi13-Jan-07 10:41
Nader Elshehabi13-Jan-07 10:41 
QuestionAccessing resource on unknown CD-ROM (drive letter). Pin
TrooperIronMan13-Jan-07 9:09
TrooperIronMan13-Jan-07 9:09 
AnswerRe: Accessing resource on unknown CD-ROM (drive letter). Pin
Luc Pattyn13-Jan-07 9:23
sitebuilderLuc Pattyn13-Jan-07 9:23 
GeneralRe: Accessing resource on unknown CD-ROM (drive letter). Pin
TrooperIronMan13-Jan-07 9:47
TrooperIronMan13-Jan-07 9:47 
GeneralRe: Accessing resource on unknown CD-ROM (drive letter). Pin
TrooperIronMan13-Jan-07 13:41
TrooperIronMan13-Jan-07 13:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.