|
|
So the tick executes again if it cannot complete it's work before the next tick is called?
|
|
|
|
|
|
Hi,
the timer event occurs after 10ms even if the first execution of event is yet to complete.
what u can do to cope this prob is set the timer enabled=false once its event execution starts so event doesnt fire again even if 10ms is over.
and when ur code execution is complete u can set enabled=true again.
Something like this<br />
<br />
timer1_Tick()<br />
{<br />
timer1.enabled=false<br />
timer1.enabled=true<br />
}
hope this works...
Nitin...
|
|
|
|
|
bankai123 wrote: Is each tick executed on a separate thread?
No, all ticks on a System.Windows.Forms.Timer run on the UI thread.
bankai123 wrote: If not, then what happens?
Every timer tick runs as a result of a WM_TIMER message being processed by the message dispatcher. Windows doesn't post the WM_TIMER message to the message queue if they are any pending messages (including WM_TIMER) in the queue. This prevents the scenario you described (a tick firing even when processing for the previous tick is executing). Note that any message in the message queue will prevent the timer from ticking, so for example, if your UI button click handler takes one second to execute, then you won't get timer ticks for that one second.
Also, note that no queuing of ticks happens, so you won't get ticks one after the other corresponding to the period when no timer ticks executed. In the above example, you won't get timer ticks corresponding to that one second period even after your button handler has completed execution.
Hope this helps.
|
|
|
|
|
Hello again,
bankai123 wrote: Is each tick executed on a separate thread?
No, but I think "System.Timers.Timer" does.
There you have to use the "Elapsed" event.
All the best,
Martin
|
|
|
|
|
Thanks for all the info, it has been helpful.
I've decided to use the System.Timers.Timer class instead, with a interval of 20ms for processing some information. I tried disabling the timer once i entered the event handler and re-enabling it after all the work is done. ( to avoid re-entrance)
However it didn't seem to work for me, It seemed to call the first elapsed event once, and doesn't seem to occur again.
I gotta debug more, not really sure where the problem lies at the moment.
|
|
|
|
|
I think this is an easy question..
I have a DataList displaying data from a ObjectDataSource and an input form that inserts data into the same table. Upon postback the DataList is showing the data prior to the postback. How do I refill the data on postback?
Id post some code but filling of dataset and databind is "magic".. here is the code Im using in the ButtonClick function:
NewsDataSetTableAdapters.CommentsTableAdapter commentsTable = new NewsDataSetTableAdapters.CommentsTableAdapter();<br />
commentsTable.Insert(newsID, subjectTextBox.Text, commentTextBox.Text, ipAddress, DateTime.Now, emailTextBox.Text);
|
|
|
|
|
It's pretty common to put the code to fill the data list in the Page_Load routine, and to place it inside an if (!IsPostBack) test since normally you only need to populate the control once, when the page loads. However, if you happen to have your population code inside this test for your particular situation, it wouldn't repopulate the control on the postback because it's explicitly told not to.
Don't know if this is how you have your code structured, but if it is, your fix may be as simple as moving the code outside the test so that it executes on every invocation of Page_Load, postback or not.
Hope this helps...
|
|
|
|
|
I am trying to use a WinForms control from another thread. Unfortunately, I can't use Control.Invoke directly, because the control calling code is hidden:
A Worker Thread modifies a DATA class. This fires an Event caught by a CONTROLLER class, which in turn tries to update a TreeView.
This doesn't work because the Node update is called from a worker thread.
(I am trying to feed my Generic Tree[^] in a worker thread)
Is there a way around it? Or do I have to change all calls in the controller to Invokes to delegates?
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
Peterchen, have you looked at the System.Windows.Forms.WindowsFormsSynchronizationContext class? Here's what you could do: let your controller class be constructed with a SynchronizationContext, then whenever you need to update the tree view, do so using the sync context. It'd look something like this:
class Controller
{
SynchronizationContext eventRaisingContext;
...
public Controller(SynchronizationContext context)
{
eventRaisingContext = context;
}
private void DataClassModifiedHandler()
{
eventRaisingContext.Post(UpdateTreeView);
}
void UpdateTreeView(object state)
{
}
}
Then, simply construct the Controller from the UI thread, like this:
Controller myController = new Controller(WindowsFormsSynchronizationContext.Current);
|
|
|
|
|
That surely gets me started... actualyl using it wasn't that bad. Only it's terribly slow, and exposes a weakness in my tree control feeder... back to the drawing board.. Anyway, thanks!
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
Ok. FYI, not sure that it matters since you're going back to the drawing board, but the SynchronizationContext.Post and SynchronizationContext.Send will boil down to Control.BeginInvoke and Control.Invoke for a WindowsFormsSynchronizationContext; shouldn't be much overhead in using SynchronizationContext.Send/Post versus using Control.Invoke/BeginInvoke.
|
|
|
|
|
feels a bit dumb to ask...
How do I test for a bit in an enum?
All examples I find combine enum values with an | - but how to check for a bit (what you do in C++ with &). (int) value & (int) flag works but that doesn't look elegant...
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
protected void mouseMoved(object sender, MouseEventArgs e) {
if ((e.Button & MouseButtons.Left)!=0) {
// ...
} else if ((e.Button & MouseButtons.Right)!=0) {
// ...
}
}
Luc Pattyn
|
|
|
|
|
I forgot the parantheses around the (a & b) ... thanks!
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
The enum really should have the [Flags] attribute, which tells the compiler that all of the values are supposed to be unique and provides a few other subtle runtime differences.
The best way to test to see if a particular value has been set is:
FileInfo info = new FileInfo(@"c:\windows\explorer.exe");
if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
}
else
{
} .NET does allow you to treat an enum without the [Flags] attribute as if it were a flags enum to some extent, but it isn't recommended. If at some point the language or the compiler rules change, using an enum in this way without the [Flags] attribute could generate a compiler warning or error.
-----------------------------
In just two days, tomorrow will be yesterday.
|
|
|
|
|
I can display results of a view I created in Sql server on a dataGrid,how would I display the same result on a txtBox ???
aPerfectTool
|
|
|
|
|
Hi
I think you want to access database tables field to show in textbox.
If below code is not your answer contact me:
SqlConnction cnn = new SqlConnection("Data Source=YourCopmputerName;Initial Catalog=YouDatabaseName;User Id=databaseUserName;Password=DatabasePassword");<br />
string strSql="SELECT id,name FROM Table1";<br />
DataSet ds = new DataSet();<br />
SqlDataAdapter da = new SqlDataAdapter(strSql,cnn);<br />
da.fill(ds,"Table1");<br />
if (ds.Tables[0].Rows.Count != 0)<br />
{<br />
TextBox1.Text = ds.Tables[0].Rows[0][1].toString();<br />
}<br />
This code get "name" column of tables from first row. you can access another cells by changing array index.
Bye
|
|
|
|
|
Hi,
I think U can achieve this in two ways.
1) Command.Text = "SELECT * FROM UR View Name (Nested of Table Name)"
2) Create one store Proc, Let the Store Proc intern selects view data by executing SELECT * FROM UR View Name.
For binding and displaying on Data Grid follow normal method.
Happy Coding
Gowda
|
|
|
|
|
Thanks guys, I got it going, your reponse helped me alot
aPerfectTool
|
|
|
|
|
hi
i want to write database application with c# 2005 and i want to set password to sqlserver 2005 database that users can not access to tables,views,....
but .. how to do ??
thanks
|
|
|
|
|
Hi
You can do this in the target system which you want to install your program on it.
But anybody can stop the sqlserver and take a copy of your database and then attach it to his/her sqlserver on another system without knowing username and password!!
I want to say it's not a cool way.
Do this to set a password to your database:
1-Open SqlServer and in Object explorer expand Security\Logins
2-Right Click and Logins and choose "New Login..."
3-In Login - New window type a LoginName and choose "Sql Server Authentication" and type password and uncheck checkboxes unless "Enforce password Policy" and Click "Ok "
4-Delete "BUILTIN\Administrator"
Now you have set password to sqlServer 2005
To set database password:
1-Expand your database and goto Security\Users
2-Right click on Users and select "New User..."
3-Type username and for import user click on button "..." front of "Login Name" and browse your user
4-Choose "db_owner" from below listbox
5-Press ok
I wish this is usefull
For more information goto:
http://forums.microsoft.com/MSDN/showpost.aspx?postid=672105&siteid=1[^]
This was my question in Msdn forum
Bye
|
|
|
|
|
main points to keep in mind in making chess in c#.
rao nasir ali khan
|
|
|
|
|