|
Hi, Luc,
thanks for your comment. I'm not disposing of the form myself. I'm just closing it. But the whole point is in not allowing the form to get disposed before all possible Invokes on it are done.
I can briefly outline what is going on in my app: a server application is calling my client app every 100 ms via COM and refreshes its state. Sometimes it happens that the server stops calling my client app and I need to detect that.
For that purpose I've written a simple timer class that's started together with the app. The core class of my app stores the timestamp of the last COM call and my timer class checks every 200 ms whether the difference between DateTime.Now() and last COM call timestamp is higher than maximum allowed. If it is, it Invokes a method on a form that's telling me the connection has been lost. If it's not, it Invokes a method on a form that's telling me the connection is OK.
Obviously, the timer runs on a separate thread from the form's thread. When I'm closing the form (which does not close the application itself), I need to make sure that the timer executes the last Invoke on the form and shuts itself off.
And there's the problem. In order to make sure that the timer executes the last Invoke on the form safely, I need to prevent the form from disposing of itself before that last Invoke is done. But if I'm preventing the form from disposing of itself by putting a lock anywhere between the moment when the form starts closing and the moment when it starts getting disposed of, I'm effectively blocking the window message queue, so the last Invoke (which is executed while the form waits on a lock) never returns.
Thanks much for any help.
Michal
|
|
|
|
|
OK, so I resolved the issue. It's certainly not the most elegant solution, but it works. I will still appreciate if someone tells me how this should be done "professionally"
Instead of a lock, I'm using an ordinary while loop. The while loop has an advantage over lock of being able to execute something while it's waiting for a signal. Lock simply sits there and does nothing until the lock is released.
So I placed the while loop inside the Form.Closing() event handler. This while loop is blocking the form from closing itself (and thus disposing of itself). Inside this loop (apart from waiting for a signal) I'm executing Application.DoEvents() every 50 ms. This ensures that the Invoke, waiting on the second thread, gets processed.
If you've got some better suggestion, please tell me.
Thanks,
Michal
|
|
|
|
|
how to display group by data in gridview
and export it to excel.
example
GROUP1
CONTENT1-A CONTENT1-B
CONTENT1-A CONTENT1-B
GROUP2
CONTENT1-A CONTENT1-B
CONTENT1-A CONTENT1-B
AND EXPORT THE EXACT INTO EXCEL
kp_chat@yahoo.co.in
|
|
|
|
|
Am relatively new to asp.net and need a challenging case study. Pls send me a VSD to prepare myself for one of the best job around.
Thanks.
|
|
|
|
|
Hei U buy by your self a**hole
|
|
|
|
|
How to iterate through every cell of a datagridview?
|
|
|
|
|
foreach(DataGridViewRow row in yourDataGridView.Rows)<br />
{<br />
foreach(DataGridViewCell cell in row.Cells)<br />
{<br />
<br />
}<br />
}
|
|
|
|
|
present functionality:
on load the datagridview's selection mode is "FullRowSelect".
on clicking "Rename" button i am changing the selection mode to "CellSelect"(only the column is editable) and selecting that cell of the selected row index and then double clicking on that cell we able type(cursor is focusing to that cell) the code is
dgvLasers.EditingPanel.Visible = true;
bEdit = true;
dgvLasers.SelectionMode = DataGridViewSelectionMode.CellSelect;
dgvLasers.Rows[intIndex].Cells[1].Selected = true;
but a small change required
on clicking "Rename" button only the cell shold be selected and cursor should be focused to that cell (i.e. without clicking on the cell we should able to type or replace the text)
please help me on this
Thanks in advance
praveen Kumar palla
|
|
|
|
|
set
datagridview.readonly = false
datagridview.editmode = editonenter
then write your code
|
|
|
|
|
How do I hide a from from which 've just loaded another.
I load formB after meeting certain criteria and wish to close the formA from wish 've loaded formB
|
|
|
|
|
form.Hide();
BTW, don't double-post...
|
|
|
|
|
Another idea would be to use the Main application program as a staging ground for each form.
if(conditionMet){
DialogResult = DialogResult.OK;
this.Close();
}
FormA formA = new FormA();
Application.Run(formA);
if(formA.DialogResult == DialogResult.OK){
FormB formB = new FormB();
Application.Run(formB);
}
|
|
|
|
|
How do I hide a from from which 've just loaded another.
I load formB after meeting certain criteria and wish to close the formAioud form from wish I load formB
|
|
|
|
|
I wish to create a report to be displayed in a browser offline in my windows application. I do not want to use crystal report.
How do I create a web based report through C#.Net 2005 version that can accept parameters without using crystal report
Or
How do I display parameters oriented values from SQL (database)on a browser offline
|
|
|
|
|
i want to pass two sting parameters in crystal report to run the query
SELECT * FROM xyz WHERE abc BETWEEN 'parameter1' AND 'parameter2'
i want to write the code on form which have crystal report viewer but i have no idea, i also searched on internet but that was not helpfull. anybody can give me code that will work than i will be your thankful.
Nikesh Kr. Yadav
CSS Infotech
Sec- 31
Gurgaon,
Haryana(India)
|
|
|
|
|
try this link.
http://www.thescripts.com/forum/thread225413.html
|
|
|
|
|
thakx but i was the same answer on google.
but its really thankx for your reply
one more thing can you answer me
how to some the number in crystal report?
Nikesh Kr. Yadav
CSS Infotech
Sec- 31
Gurgaon,
Haryana(India)
|
|
|
|
|
hi, i have a question. imagine i have a window form and in it i have a panel. now, i need to do a mousedown on the form and then mouseup in the panel. The idea here is to create a drag and drop action. However, the by creating those events, it does not seem to work because the mouseup event is never called although i click on the mouse on the form and then hold and finally release in the panel area.
What events should i use since this can''t work?
Thanks in advance.
|
|
|
|
|
Why don't you just use the drag & drop functionality a form already supports.. It will save you a lot of headache!
|
|
|
|
|
Hello,
The trick is to handle the MouseUp from the form as well, and check if the Cursor is in the Panel range.
Point pt = yourPanel.PointToClient(Cursor.Position);
Rectangle rc = yourPanel.ClientRectangle;
if (rc.Contains(pt))
{
}
Hope it helps!
All the best,
Martin
|
|
|
|
|
Hi,
I am creating a developing screensaver in C#. I have done everything to create screensaver. Now I am stuck in a problem. How to create a scr file ? I have renamed the exe to scr. However, if I right click the scr file and select the install option, my antivirus prompts a suspicious activity. Any help on this ?
Thanks,
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg."
- Bjarne Stroustrup
|
|
|
|
|
Identity Undisclosed wrote: How to create a scr file ? I have renamed the exe to scr
That's it!
Identity Undisclosed wrote: However, if I right click the scr file and select the install opti
You don't need to install it!
Just copy it in the "Windows" directory.
All the best,
Martin
|
|
|
|
|
Hi!
Is there some way to get the same color of the GroupBox Heading and put it on a Label? The color is different depending on which Xp theme you are using.
/Mjelten
|
|
|
|
|
Enumeration System.Drawing.KnownColors contains all of the system defined colours. The Groupbox heading will be one of these - but you'd probably need to experiment to work out which one.
|
|
|
|
|
Ok, thanks but how do get access to the color
I can not set label1.ForeColor = System.Drawing.KnownColor.something
error: Cannot implicitly convert type 'System.Drawing.KnownColor' to 'System.Drawing.Color'
|
|
|
|