Exemplo n.º 1
0
        private void populateClubsDropDownThread()
        {
            Trace.WriteLine("FCompetitors: populateClubsDropDownThread() " +
                            "started on thread \"" +
                            Thread.CurrentThread.Name +
                            "\" ( " +
                            Thread.CurrentThread.ManagedThreadId.ToString() +
                            " )");

            lock (populateClubsDropDownThreadLock)
            {
                // Get the teams from the database
                Structs.Club[] clubs = CommonCode.GetClubs();
                DatasetTeams   ds    = new DatasetTeams();

                foreach (Structs.Club club in clubs)
                {
                    DatasetTeams.ClubsRow row =
                        ds.Clubs.NewClubsRow();
                    row.ClubId   = club.ClubId;
                    row.ClubName = club.Name;
                    ds.Clubs.AddClubsRow(row);
                }
                this.DdClubs.DataSource    = ds.Clubs;
                this.DdClubs.ValueMember   = "ClubId";
                this.DdClubs.DisplayMember = "ClubName";
            }
            Trace.WriteLine("FCompetitors: populateClubsDropDownThread() ended.");
        }
Exemplo n.º 2
0
        internal void UpdatedClubs()
        {
            try
            {
                Trace.WriteLine("FClubs.updatedClubs() started on thread " +
                                Thread.CurrentThread.Name + "\" ( " +
                                Thread.CurrentThread.ManagedThreadId + " )");

                Trace.WriteLine("FClubs.updatedClubs()  locking \"updatedClubsThreadLock\"...");

                lock (_updatedClubsThreadLock)
                {
                    Trace.WriteLine("FClubs.updatedClubs()  locked \"updatedClubsThreadLock\".");
                    _clubs = _commonCode.GetClubs();

                    //clubTable.Clear();
                    // Create one DataTable to bind dropdown with
                    _clubTable = new DataTable();
                    var colName = new DataColumn("Name", Type.GetType("System.String"));
                    _clubTable.Columns.Add(colName);

                    var colId = new DataColumn("Id", Type.GetType("System.String"));
                    _clubTable.Columns.Add(colId);

                    // add default value
                    var newRow = _clubTable.NewRow();
                    newRow["Id"]   = NewClubValue;
                    newRow["Name"] = NewClubText;
                    _clubTable.Rows.Add(newRow);

                    foreach (var club in _clubs)
                    {
                        newRow         = _clubTable.NewRow();
                        newRow["Name"] = club.Name;
                        newRow["Id"]   = club.ClubId;
                        _clubTable.Rows.Add(newRow);
                    }

                    if (InvokeRequired)
                    {
                        Invoke(_bindClubsTable);
                    }
                    else
                    {
                        _bindClubsTable();
                    }
                }
            }
            finally
            {
                Trace.WriteLine("FClubs.updatedClubs() unlocking \"updatedClubsThreadLock\".");
                Trace.WriteLine("FClubs.updatedClubs() ended.");
            }
        }