Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hello Friends,
 
I am getting one strange problem.
I have code like below.
 
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 16-Sep-12 19:29pm
VIPR@T2.8K
Edited 16-Sep-12 19:31pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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:
try
{
    GridUtitlity.strFind = tsTxtSearch.Text.Trim();
    MessageBox.Show("Hello");
    /*
     *  Your code goes here
     */
}
 
--Amit
  Permalink  
Comments
VIPR@T at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 1,518
1 OriginalGriff 478
2 Manas Bhardwaj 394
3 Tadit Dash 310
4 Damith Weerasinghe 260
0 Sergey Alexandrovich Kryukov 9,575
1 OriginalGriff 5,856
2 Peter Leow 4,405
3 Maciej Los 3,540
4 Abhinav S 3,513


Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid