|
Is there a more efficient timer than the standard one? I am using on on a 1 second tick, and it's lagging my app badly
|
|
|
|
|
Depends how you are using it, but it shouldn't cause a noticable lag.
only two letters away from being an asset
|
|
|
|
|
Im using a System.Timers.Timer, which runs when the app loads.
The lag happens on each tick, might it be the code within the tick thats causing the lag rather than the timer? (Its calling a tiny xml feed from a server).
Would the loading of the xml page cause the lag do you think?
|
|
|
|
|
It's definitly not the Timer that's causing the lag. It's got to your Tick code. The lag is probably comming from the time it takes to get the file from the server.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ah, damn. You reckon if I tried multi threading the xml retrieval it might stop the lag at all?
|
|
|
|
|
You'd have to move the code to another thread to avoid the lag. Check into using the System.Threading.Timer instead. Your code will be called on a background thread using this Timer.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
What Timer are you using now? The FrameworkTimer in the DirectX SDK is the fastest in .net...
/\ |_ E X E GG
|
|
|
|
|
Hi folks,
Does anyone know of a way I can convert a string into a resource?
Ie, like this?
String sound_file = (myResource);
<do convert here>
spWave.Stream = sound_file;
Basically I need the string to be a properties.resource value...
Thanks, Ben.
-- modified at 16:30 Friday 4th August, 2006
|
|
|
|
|
You want to add a string into the resources during runtime? That isn't possible because the resources are contained within the static executable.
Why do you need to add a string to your resources?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
I dont want to add the string as a resource, but reference the resource from a string.
So if I want to play the resource: Properties.Resources.mysound;, I want the string sent to the function to represent mysound.
|
|
|
|
|
I still don't understand. If you want to play the resource Properties.Resources.mysound, you'll need to convert it to a stream or file and use System.Media.SoundPlayer to play the sound.
You said "I want the string sent to the function to represent mysound". Can you clarify that? What string? What function?
|
|
|
|
|
I have an unmanaged C++ DLL which has the following structures,
typedef struct {char str[200]; } MYARRAY1;
typedef struct {MYARRAY1 myarray1struct;} MYARRAY2;
typedef struct {MYARRAY2 myarray1struct[5];} MYARRAY3;
To return MYARRAY2, I used the following entry function,
extern "C" __declspec(dllexport) void CallTestArray2( MYARRAY2 *pStruct)
To return MYARRAY3, I used the following entry function,
extern "C" __declspec(dllexport) void CallTestArray3( MYARRAY3 *pStruct)
In C#, I declared the following structures,
[StructLayout(LayoutKind.Sequential)]
public struct MyArray1
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=200)] public String str;
}
[StructLayout(LayoutKind.Sequential)]
public struct MyArray2
{
public MyArray1 tempArray1;
}
[StructLayout(LayoutKind.Sequential)]
public struct MyArray3
{
public MyArray2[] tempArray2;
}
I do not have any problem using DLLImport call to C++ DLL to get data in MyArray2, however when I try to get data in MyArray3 with the following code, all data in testArray3 are empty.
MyArray3 testArray3 = new MyArray3();
testArray3.tempArray2 = new MyArray2[ 5 ];
CallTestArray3(ref testArray3);
Any help is appreciated!!!
|
|
|
|
|
vitowong wrote: [StructLayout(LayoutKind.Sequential)]
public struct MyArray3
{
public MyArray2[] tempArray2;
}
Underlined should be also marshaled.
|
|
|
|
|
MyArray2 is based on MyArray1, and MyArray1 has been marshaled. Is it need for MyArray2[] be marshaled? I tried to marshal as AsAny, but it doesn't work. What do I be marshal as? Thanks.
|
|
|
|
|
I am building an application that must take one Dataset table apart and display it in two different DataGridView's along with one additional field from a second table.
I'm iterating through the transactions and building out a DataTable for each set of records. (this part works nicely) Then set my grids as follows:
payView.DataSource = new DataGridView( payData );
refView.DataSource = new DataGridView( refData );
So far so good, everything works...almost. I have one column defined as a DataGridViewCheckboxCell and that column is not bound to any data. The remaining columns ARE bound to my fields in my data tables and all of them are readonly. My DataGridViewCheckboxCell is marked as ReadOnly=false and I even tried marking my DataGridView as ReadOnly=false. All to no avail. If I click on it, the cell never changes value and remains unchecked. Here is my column definition:
this.selected1 = new DataGridViewCheckBoxColumn();
this.selected1.ReadOnly = false;
this.selected1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.selected1.HeaderText = "Sel";
this.selected1.Name = "paymentSelect";
this.selected1.Resizable = System.Windows.Forms.DataGridViewTriState.False;
Finally I wanted to highly a cell that fell outside the allowed parameters. The logic works well. The cell is identified and the cell.Style was set to a new highlightedStyle object with a light red background color. However the DataGridView never changes the background painting. The only way I got it to work is by hooking into the RowPrePaintEvent and setting the background color there. Why is it working like this??? Why is this control being so difficult to work with????
Any help in getting the checkbox to function properly would be greatly appreciated.
|
|
|
|
|
Unbound CheckBoxColumn works fine here, just click Colums property of the DataGridView in the designer, add the unbound column, and voila, perfectly editable. Here's the designer generated code:
private void InitializeComponent() {<br />
this.dataGridView1 = new System.Windows.Forms.DataGridView();<br />
this.Column1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();<br />
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();<br />
this.SuspendLayout();<br />
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;<br />
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {<br />
this.Column1});<br />
this.dataGridView1.Location = new System.Drawing.Point(-4, -1);<br />
this.dataGridView1.Name = "dataGridView1";<br />
this.dataGridView1.Size = new System.Drawing.Size(297, 271);<br />
this.dataGridView1.TabIndex = 0;<br />
this.Column1.HeaderText = "Column1";<br />
this.Column1.Name = "Column1";<br />
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);<br />
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;<br />
this.ClientSize = new System.Drawing.Size(292, 268);<br />
this.Controls.Add(this.dataGridView1);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();<br />
this.ResumeLayout(false);<br />
}<br />
Wout
|
|
|
|
|
Yes, well I'm not build the columns in the designer. I'm building them in code.
|
|
|
|
|
The designer writes code, and I showed the working generated code... So it should work too if you type this manually if you prefer that.
Wout
|
|
|
|
|
Hello ...
I would like to create a sample messagbox which suppoted the
visual style office 2003.
I create a UserControl which inherits from
system.Windows.Forms.MessageBox (override paint method) ...
unfortunly I can`t intherits from messagebox!
Please tell me what I have to done to get a MessagBox which
supports the Office 2003 style.
best regards....
|
|
|
|
|
Just create a form which inherits from user control, slap your a label, image, and buttons on there and you're good to go. A MessageBox is just a type of form, after all.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Messianic Instrumentals (with audio)
The apostle Paul, modernly speaking: Epistles of Paul
Judah Himango
|
|
|
|
|
What's the proper way of overriding Dispose(bool disposing); in a UI control? The method is already overridden in the designer generated file in .NET 2.0. I never edit that file manually, so how are you supposed to override it then? Or is the proper way to add stuff to the components field, which gets cleaned up by the Dispose method? Then I have to make the disposable objects IComponent objects, slightly more work then I'd like to do.
Wout
|
|
|
|
|
// an example of the IDispose pattern
private System.ComponentModel.IContainer components = null;
public void Dispose()
{
this.Dispose(true);
}
protected internal void Dispose(bool disposing)
{
if ( disposing && components != null )
components.Dispose();
base.Dispose(disposing);
}
|
|
|
|
|
Yes yes, I'm not a moron. I'm wondering how I'm supposed to override the ALREADY OVERRIDDEN Dispose method present in the designer generated file, without touching that file.
Sorry, I'm not angry.
Wout
|
|
|
|
|
Quote: What's the proper way of overriding Dispose(bool disposing); in a UI control? :EndQuote
I answered what you asked.
If the Dispose method is already overriden and not made virtual, then you cannot override it.
|
|
|
|
|
You overlooked the "overriding" part?
My first feeling is too that I can't override without touching the designer file. That would be utterly stupid, and I can't believe that. So there must be a way of hooking into the Dispose... Maybe I should add the disposable part to the components field, at least that works.
Wout
|
|
|
|