Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
try
            {
                Stopwatch stpcycle = new Stopwatch();
                stpcycle.Start();
                Trace.TraceInformation("SSCCAdded on grid  {0},{1},{2}", DateTime.Now.ToString(), SSCCCode, deck.ToString());
                DataGridView DGSSCC  = RetDG(deck);
                
                if (DGSSCC == null) return;
               
                //if (DGSSCC.InvokeRequired == true)
                //{
                //    InvokeUIHandlerG d = new InvokeUIHandlerG(SSCCAdded);
                //    this.Invoke(d, new object[] { SSCCCode, deck });

                //}
                if (DGSSCC.InvokeRequired)
                {
                    InvokeUIHandlerG d = new InvokeUIHandlerG(SSCCAdded);
                    DGSSCC.BeginInvoke(d, SSCCCode, deck);
                }

                else

                {

                    string SSCC = Convert.ToString(SSCCCode);
                    string printedSSCC = string.Empty;
                    for (int i = 0; i <= DGSSCC.RowCount - 1; i++)
                    {
                        printedSSCC = (string)DGSSCC[(int)DGSSCC_Col.TertiaryUID, DGSSCC.Rows[i].Index].Value;                       
                        if (printedSSCC == SSCC || string.IsNullOrEmpty(SSCC))
                        {
                            return;
                        }
                    }

                    object[] param = new object[3];
                    Trace.TraceInformation("SSCC ADDED INdex " + (CaseStartVal + DGSSCC.Rows.Count));
                    param[(int)DGSSCC_Col.CaseNum] = (CaseStartVal + DGSSCC.Rows.Count);
                    if (Globals.JobType == PTPL.JOB.Cust_GTIN_JbTypes.CIP.ToString() && deck.IsTertiaryDeck() == false)
                        param[(int)DGSSCC_Col.TertiaryUID] = string.Empty;
                    else
                        param[(int)DGSSCC_Col.TertiaryUID] = SSCCCode;
                    param[(int)DGSSCC_Col.UIDVerified] = false;

                    DGSSCC.Rows.Add(param);

                    int Index = DGSSCC.RowCount - 1;
                    if (Globals.App_Setting.Instance.uSER_SETTINGS.IsSortVerifySSCCTabDescending)
                    {
                        Index = 0;
                        DGSSCC.Sort(DGSSCC.Columns[(int)DGSSCC_Col.CaseNum], ListSortDirection.Descending);
                    }
                    else
                    {
                        DGSSCC.Sort(DGSSCC.Columns[(int)DGSSCC_Col.CaseNum], ListSortDirection.Ascending);
                    }
                    DGSSCC.Rows[Index].Cells[(int)DGSSCC_Col.TertiaryUID].Style.Font = new Font(DGSSCC.Font, FontStyle.Regular);
                    DGSSCC.Columns[(int)DGSSCC_Col.UIDVerified].Visible = true;
                    if (deck.IsTertiaryDeck())
                        DGSSCC.Columns[(int)DGSSCC_Col.UIDVerified].ReadOnly = true;

                    if (DGSSCC.RowCount == 1)
                    {
                        DGSSCC.Rows[Index].Selected = true;
                        scrollGrid(DGSSCC);
                        DGSSCC[(int)DGSSCC_Col.UIDVerified, Index].Value = true; //for visibility issue
                        DGSSCC[(int)DGSSCC_Col.UIDVerified, Index].Value = false;
                        //UpdateParentVerification(DGSSCC[(int)DGSSCC_Col.SSCC, Index].Value.ToString(),false);
                    }
                    else
                    {
                        DGSSCC[(int)DGSSCC_Col.UIDVerified, Index].Value = false;
                    }
                    DGSSCC.Refresh();

                    Jobdeck JD = Jobdeck.RetJobDeck(deck);

                    if (JD.printer != null && JD.printer.IsLinePrinter)
                    {
                        BTN_REPRINTLast.Enabled = false;
                    }
                    else
                    {
                        if (DGSSCC.Rows.Count == 0)
                            BTN_REPRINTLast.Enabled = false;
                        else
                            BTN_REPRINTLast.Enabled = true;
                    }

                    if (DGSSCC.Rows.Count == 1)
                    {
                        dg_ColumnHeaderMouseDoubleClick(DGSSCC, null);// added for proper allignment of datagrid
                    }
                    if (Globals.App_Setting.Instance.uSER_SETTINGS.IsSortVerifySSCCTabDescending)
                    {
                        DGSSCC.Sort(DGSSCC.Columns[(int)DGSSCC_Col.CaseNum], ListSortDirection.Descending);
                    }
                }
                stpcycle.Stop();


What I have tried:

I have tried DGSSCC.InvokeRequired Method with Datagridview ID, but still Performance Issue in software. Execution time increased if large amount data come in DataGridView.
Posted
Updated 17-Jun-20 3:13am
v2
Comments
Richard MacCutchan 15-Jun-20 4:45am    
I don't see any reference to multi-threading in that code. And how many rows in the DataGridView are you talking about?
Rahul S Ghige 15-Jun-20 4:50am    
Hi Richard, Thanks for your reply.
About DataGridView there many rows like 80000 or more.
as i mentioned i want increase performance only, now ignore multi threading reference. because this method take longer time to execute if records more than 50000
Richard MacCutchan 15-Jun-20 5:19am    
You cannot seriously expect your users to page through 80,000 records to find the one they are interested in. Your design needs to be changed.
[no name] 16-Jun-20 12:55pm    
Ever heard of "data virtualization"? "Paging"? Look it up.

1 solution

My advice is to find a 3rd party listview/listbox control that allows you to group and sort.

Failing that, load all the data, but force the user to specify search terms and only display records that meet the search criteria.

Another approach is to force the user to specify search terms, but perform your database query to load data based on those search criteria (essentially, implementing an ad-hoc query system).
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900