Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hello Friends,

I am getting one strange problem.
I have code like below.

C#
private void tsTxtSearch_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (tsTxtSearch.Text != "")
            {
                if (e.KeyChar == (char)Keys.Enter)
                {
                    try
                    {
                        GridUtitlity.strFind = tsTxtSearch.Text.Trim();
                        frmReviewSummary.lstFindRef.DataSource = null;
                        rowIndex = 0;
                        roles.Clear();
                        
                        List<int[]> listSMS = GetSearchArrayFromGrid(frmReviewSummary.dgSMS);
                        frmReviewSummary.dgSMS.DataSource = GridUtitlity.dtSMS;
                        frmReviewSummary.dgSMS.CellPainting += new DataGridViewCellPaintingEventHandler(dgSMS_CellPainting);
                        
                        frmReviewSummary.lstFindRef.DataSource = roles;
                        frmReviewSummary.lstFindRef.DisplayMember = "Name";
                        frmReviewSummary.lstFindRef.ValueMember = "Id";
                        frmReviewSummary.contFindref.Show(frmReviewSummary.dockPanel1);
                        frmReviewSummary.contFindref.DockState = DockState.DockBottom;
                        frmReviewSummary.contFindref.Focus();
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
        }


This code is working in fine when i check using debugger. But when i remove my debug point its not working. i am not getting what happening. If i keep debug point then its working fine and if i remove the debug point its not working.
Can any one please help in this?

Thanks,
Viprat
Posted
Updated 16-Sep-12 19:31pm
v2

Right way of asking question.
Add a MessageBox inside try block and check without putting a break-point. Whether the debugger is coming inside or not. Clean and rebuild your solution.
Try this:
C#
try
{
    GridUtitlity.strFind = tsTxtSearch.Text.Trim();
    MessageBox.Show("Hello");
    /*
     *  Your code goes here
     */
}


--Amit
 
Share this answer
 
Comments
VIPR@T 17-Sep-12 1:41am    
I had check using MessageBox is well. This Event is going to call. But not giving me desired out put. If u put debug point and check then its working. I had tried with key_down event is well. But the same problem.
Hi,

Possiblity of this behavior is,

You are calling some long running Thread function that is not yet completed and You are trying to get the value updated by that thread. In such scenario debug will work as there is delay between next line execution. To check such issue, you need to add some Thread.Sleep.

I found such a place in your code. Display the message of listSMS count(As in Solution1 by _Amy). If it gives the correct result then look for your other code.
 
Share this answer
 

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