|
Yeah I know.
I have just mentioned that it's urgent.It doesn't mean that I am paying anyone.
Is this a way to talk to anyone??
if you or anybody doesn't want to give answers please keep silent.nobody is forcing you to give the answers.
adil kazmi
|
|
|
|
|
You have to understand that there are a lot of posts on the boards where they are urgent or must be done ASAP, etc. The simple fact is, the people on these boards volunteer their time for free and trying to hype something up like this doesn't impress them, or make them want to help any more urgently.
Please read this[^] article, especially the sections headlined "This is not a support forum" and "Replies" to understand why people react this way.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello,
how do I safely invoke a delegate on my windows form if I can't eliminate the possibility that the form gets disposed BETWEEN me checking whether it is disposed and the invoke code itself?
Randomly I'm getting an exception that says I can't access the disposed object. It's absolutely clear that I can't access a disposed object, but how do I make sure it's indeed NOT disposed if it can still get disposed right after I check whether it is disposed?
Consider this example that looks correct, but produces the above mentioned exception from time to time:
if (!MyForm.IsDisposed)
{
MyForm.Invoke(MyDelegate);
}
Form.Disposing doesn't help neither.
Thanks very much for any input,
Michal
-- modified at 7:24 Wednesday 25th July, 2007
|
|
|
|
|
It helps to set a flag that the form is closing and check for that flag before the invoke, but it's not an elegant solution and it might still throw an exception if the flag is set after checking for the flag and the form gets disposed before executing the invoke.
Any ideas?
Thanks,
Michal
|
|
|
|
|
How about wrapping both your protected override void Dispose(bool disposing) -method and your invoke-procedure in a lock(...) -block?
Ref.: http://msdn2.microsoft.com/en-us/library/c5kehkcz(vs.80).aspx
|
|
|
|
|
Cool, thanks a lot! This solutions seems to work.
Next time, I'll be wiser and will use lock for this kind of situation.
Thanks much again!!
Michal
|
|
|
|
|
are you kidding ?
the Dispose() method is the one that typically will be executed by the finalizer thread.
Do you think it will appreciate your lock ?
if the finalizer cant do its job, the GC has less memory to manage and recycle;
do you want the GC to run out of memory for no good reason ?
I am not sure what the right answer is, but what you propose seems very wrong to me.
|
|
|
|
|
Actually, it does not appreciate my lock
If I'm forcing the Dispose() to wait on the lock until all Invokes are done and until I make sure there are no Invokes going to be done in the future, I'm effectively blocking that form's Window Message Queue.
If I'm blocking the Window Message Queue, the Invoke never returns.
Obviously, the same happens (WMQ block => Invoke never returns) if I try, for instance, to block after Form.Closing event etc.
So I'm back at the beginning
Any suggestions?
Thanks,
Michal
|
|
|
|
|
I'm sure I would have some suggestions (or at least comments) if I felt I understood
your problem. You seem to somehow Dispose() of a form, while you may still need it.
So I need more info (contextual I guess).
For what it's worth: I typically dont dispose of forms, I just close them.
I realize you may want to avoid Close() so you can play with Hide() and Show() again,
but even then the last time you could Close() rather than Dispose(), couldnt you ?
|
|
|
|
|
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
|
|
|
|