|
|
Jared, thanks for your comment!
Of course, you're right. That way I can block the second thread until the first call to the event handler is finished.
The dialog can still pop up twice in a row (when I click the menu item in the main app and afterwards the other thread fires the event), but I think I'll use this approach nevertheless.
Or do you have any further suggestions on how to really discard every other call?
Thanks,
mav
|
|
|
|
|
The only way I can think of is having a volatile bool variable that is set before Invoke and is reset after it. That way, you can simply return if the flag is set.
class XYZ
{
volatile bool isMessageBoxVisible = false;
void Func()
{
lock(this)
{
if (isMessageBoxVisible) return;
isMessageBoxVisible = true;
}
this.Invoke(...);
lock(this) { isMessageBoxVisible = false; }
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks!
That could be a way, but then it gets quite messy, because I allow the user to configure which menu item or toolbar button is pressed when a certain button on the external input device is clicked.
So I'd have to create a variable for each and every menu item/toolbar button...
I was looking for a behaviour like what you get when you use the mouse to click a menu item/tbb. A modal dialog can pop up, but then the UI of the main window is not accessable any more and thus the same menu item/tbb can't be pushed more than once. And the additional clicks aren't queued but discarded.
Something like
if (mainForm.IsIdle)
this.Invoke(... But just as I write this I got another idea:
I usually set the form's Cursor to Cursors.WaitCursor at the beginning of my menu/toolbar event handlers and reset it to Default in a finally block.
This information can be used to decide whether the main form is busy (executing an event handler) or not. I think I'll try it like this:
if (mainForm.Cursor == Cursors.Default)
this.Invoke(...
Thank you all for your help!
mav
|
|
|
|
|
i wrote a sales report, which works fine with my application if i include start date and end date in the database, {gndsale.dob} in {date.startdate} to {date.enddate}.
but if i change the report to pass Parameter Fields, {gndsale.dob} in {?Start Date} to {?End Date}
when i load the report first time it's okay i can see the correct parameters on the Page header and in Details, but if i load report 2nd time with different parameters , the page header is updated but the details not, some how i need to refresh crystalReportViewer1 after i pass parameters. ???
check this code
ReportDocument1.Load(RptPath.ToString());
crystalReportViewer1.RefreshReport();
crystalReportViewer1.ReportSource = reportDocument1;
paramFields = new ParameterFields ();
ParameterField crParamFld = new ParameterField();
ParameterDiscreteValue CrparamValue = new ParameterDiscreteValue();
paramFields = crystalReportViewer1.ParameterFieldInfo;
crParamFld = paramFields[0];
CrparamValue.Value = PassDT_Start;
crParamFld.CurrentValues.Add(CrparamValue);
ParameterField crParamFld_2 = new ParameterField();
ParameterDiscreteValue CrparamValue_2 = new ParameterDiscreteValue();
crParamFld_2 = paramFields[1];
CrparamValue_2.Value = PassDT_End;
crParamFld_2.CurrentValues.Add(CrparamValue_2);
crystalReportViewer1.ParameterFieldInfo = paramFields;
crystalReportViewer1.ReportSource = reportDocument1;
Or this code
reportDocument1.SetParameterValue("Start Date",PassDT_Start );
reportDocument1.SetParameterValue("End Date",PassDT_End );
crystalReportViewer1.RefreshReport();
crystalReportViewer1.ReportSource = reportDocument1;
|
|
|
|
|
Hello,
I’m programming an MDI application. My application contains a sizable child form and a fixed dialog form. The problem is that when I maximize the sizable form, the fixed dialog form is maximised too. I don’t know how to keep the fixed dialog form in its normal state while the sizable child form is maximized. Has any one a solution? Thanks.
|
|
|
|
|
Is the dialog form an MDI Child form? If so, you can't seperate the two. If one MDI Child is maximized, they're all maximized. There is no way to stop that from happening. The solution is to make the dialog form a normal form, not an MDI Child.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The Error:
Could not find file "\\myserver\share$\myfile.txt".
The Code:
File.Copy(@"\\myserver\share$\myfile.txt",@"c:\myfile.txt"), true);
The file is there. The premissions on the share$ is set to everyone. I can navigate to the file using the above quoted string. What am I missing?
|
|
|
|
|
|
Hi!
I guess the problem lies in the share itself.
If you enter "\\myserver\share$" in the address bar of a windows explorer, do you get a dialog asking for a user name and password?
If you can see the file in your explorer, does the program still throw the exception afterwards?
Or is the code executed from within a windows service process running under LocalSystem account?
mav
|
|
|
|
|
thank you for responding...
no.. no dialog box appears. Any lowly person in the company and open this share no problem.
And the code is being executed by ASPNET account
|
|
|
|
|
i think i've boiled down the issue. ASPNET service account is a local service account to my machine. I'm trying to copy a file from a domain server. The premissions on the server is set to everyone, but that means everyone in the Domain, not local mcahin accounts. Now I need to figure out how to pass premissions with my file.copy... any clues?
|
|
|
|
|
You don't.
You can create a domain account, restrict it's log to certain machines!, that the ASP.NET server can run under. It doesn't have to run under a local machine account!
Then you can give that domain account appropriate rights to the machines and folders required to run your code and do file copies.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Maybe the parameter are incorrect you can try with the ip:
File.Copy(@"\###.###.###.###\directory\file.txt",@"c:\file.txt",true);
I can use the instruction like my example and work well.
|
|
|
|
|
Hi,
I will retrive a lot of data from database into a datatable and display these records into user interface as a datagrid or datarepeater. The problem is the data has to be retrived again from database every time when I want to narrow down the search result or even just go to different pages of the datarepeater.
Is there anyway to save the table records so that I can use the data dirctly instead of connect to sql server everytime. I dont want to save it into a session, coz it could be expired anytime.
Thanks.
|
|
|
|
|
Hi there,
There are some options come to mind, IMO:
- using cache mechanism
- using export the datatable to temporary xml file
<< >>
|
|
|
|
|
Create a DataView from the DataTable, and display that. apply filters, page selection logic to the datatable to create the dataview.
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
I thinking caching is the best alternative to ur problem. U can then also set dependency with ur database. By that way if in the meanwhile database had been modified, u can know it as ur cache will get empty....
Regards,
Sandeep
+919891027854
|
|
|
|
|
I have a DataSet that contains a table "results" which is popuated with data from a database.
I need to know the number of rows in the "results" table. Is there a simple way to grab this information? A property or some such? Thanks.
|
|
|
|
|
DataSet.Tables[0].rows.count
|
|
|
|
|
|
Wouldn't DataSet.Tables["tablename"].Rows.Count be more appropriate? Just in case that table is not #0 in the list?
|
|
|
|
|
|
|
Hi All.
I writing some application and in it i wrote some Log file that will be as instance in each class and in each class that use the log - will able to send string to the log file.
I have some problem that create some exception in my log file.
In log class i have method call "Write" that getting string and writing it to file.
In the end of method "Write" the log class close the file by doing this line
if (m_cFileStream!= null)
m_cFileStream.Close();
After i call the "Write" class again i getting Exception in the line that do :
StreamWriter cStreamWrite = new StreamWriter(m_cFileStream);
[The variable m_cFileStream is not a null and he hold the same information they were in it before calling the block that close the FileStream]
I realy dont understand why i getting an exception and how to solve this problem.
Someone can Help me ??
|
|
|
|