Hi Guys,
I am working on a C# windows application. I am facing a wierd problem in my code. I am using a dropdown to get some date. There are two events to change the value, one for ValueSelected and another for ValueChanged. Whenever I run that code while debugging, it show the correct date but when I run that code w/o debugging, it always shows wrong date. I also print the StackTrace in both mode. I found that codes call different methods in different mode. Here is the Code and Stack Trace:
Code :
void cboPeriod_ValueSelected(object sender, PDIMultiColValueSelectEventArgs e)
{
DataRow dr = cboPeriod.LookupGrid.CurrentRow;
m_ThruDate = Convert.ToDateTime(libDataSetUtil.GetColValue(dr,
TC_Calendar_Detail.F_ENDINGDATE, m_NextPeriodBegDate.AddDays(-1) + M_ALL_DAY_LONG));
m_FromDate = Convert.ToDateTime(libDataSetUtil.GetColValue(dr, TC_Calendar_Detail.F_BEGDATE,
m_CurPeriodBegDate));
OnValueChanged();
}
void cboPeriod_ValueChanged(object sender, EventArgs e)
{
DataRow dr = cboPeriod.LookupGrid.CurrentRow;
m_ThruDate = Convert.ToDateTime(libDataSetUtil.GetColValue(dr,
TC_Calendar_Detail.F_ENDINGDATE, m_NextPeriodBegDate.AddDays(-1) + M_ALL_DAY_LONG));
m_FromDate = Convert.ToDateTime(libDataSetUtil.GetColValue(dr, TC_Calendar_Detail.F_BEGDATE,
m_CurPeriodBegDate));
OnValueChanged();
}
With Debugging :
at profdata.com.GeneralLedger.frmGLRPTTrialBalance.datPeriodDate_ValueChanged(Object sender, EventArgs e)
at profdata.com.Controls.PDIDatePicker.OnValueChanged() in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIDatePicker.cs:line 3804
at profdata.com.Controls.PDIDatePicker.cboPeriod_ValueChanged(Object sender, EventArgs e) in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIDatePicker.cs:line 3018
at profdata.com.Controls.PDIMultiCol.OnValueChanged() in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIMultiCol.cs:line 2415
at profdata.com.Controls.PDIMultiCol.set_Value(String value) in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIMultiCol.cs:line 894
at profdata.com.Controls.PDIMultiCol.SelectValue() in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIMultiCol.cs:line 1753
at profdata.com.Controls.PDIMultiCol.m_Grid_Click(Object sender, EventArgs e) in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIMultiCol.cs:line 1351
at System.Windows.Forms.Control.OnClick(EventArgs e)
at profdata.com.Controls.PDIDataGrid.OnClick(EventArgs e) in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIDataGrid.cs:line 5108
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
Without Debugging :
at profdata.com.GeneralLedger.frmGLRPTTrialBalance.datPeriodDate_ValueChanged(Object sender, EventArgs e)
at profdata.com.Controls.PDIDatePicker.OnValueChanged() in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIDatePicker.cs:line 3804
at profdata.com.Controls.PDIDatePicker.cboPeriod_ValueSelected(Object sender, PDIMultiColValueSelectEventArgs e) in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIDatePicker.cs:line 3007
at profdata.com.Controls.PDIMultiCol.OnValueSelected(PDIMultiColValueSelectEventArgs e) in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIMultiCol.cs:line 1733
at profdata.com.Controls.PDIMultiCol.SelectValue() in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIMultiCol.cs:line 1756
at profdata.com.Controls.PDIMultiCol.m_Grid_Click(Object sender, EventArgs e) in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIMultiCol.cs:line 1351
at System.Windows.Forms.Control.OnClick(EventArgs e)
at profdata.com.Controls.PDIDataGrid.OnClick(EventArgs e) in D:\PDI\Sandboxes\Ent_6.8.RU.Dev\Enterprise - WS\Lib\PDICtlSet1\ctlPDIDataGrid.cs:line 5108
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
As you can see (the bold part in both stach trace), both stack traces are different. Without debugging, it is not calling the cboPeriod_ValueChanged event but calling cboPeriod_ValueSelected which should be called after ValueChanged or should not call. So do anyone have any idea that why this is happening.
My Understanding: If I am giving this code a break (like hitting a breakpoint, putting message box or let the thread sleep for sometime, it works fine)
Sorry for this long question. :(