|
The Windows task scheduler has an option to not start a new instance if the task is already running.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you very much.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Hi Richard,
Can you please give me the name of the option if you don't mind?
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
It's at the bottom of the "settings" page:
Screen-shot[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That could be answered in a few minutes by testing it. Create a task that writes somewhere for one minute. Start them from your service or the Task-scheduler, with an interval of 10 seconds.
So, unless you do something that locks (writing to files and the like) it should not fail.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you very much
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
If you can add the request to in-memory .net queue it should solve your problem. Keep a thread which will monitor and trigger job from the queue. This way you can decide on a number of threads which can run parallelly (one or multiple).
Ashwin Shetty
|
|
|
|
|
Hi,
I have a Console application which has to be repeatedly executed with some intervals. For that what I have done is, in main I have called the method that performs the action after that I put the Main into sleeping for a minute or so and then reexecuted it.
Here is my Code:
static void Main(string[] args)
{
ApplicationOrNamespaceName = typeof(Watcher).Namespace.ToString();
ClassName = "Watcher";
while (true)
{
RecordFile();
System.Threading.Thread.Sleep(1000 * 60 * WatcherDB.GetCycleTimeForLoopingTheApplicationForEnvironment());
}
}
My question is, is it suggestible? OK? can this code bad for performance? or if you have any better approaches for performance please help me, any advice, link or code snippet is appreciated. Here I didn't use Windows Service or Scheduled Task because if the application is running and if Windows Service tries to access it again, then its a problem, maybe not true, but that's what I have thought. But any suggestions also fine my friends.
Thanks in advance my friends.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
You're getting down-voted because you're not thinking.
You put the thread to sleep! What is there to discuss in the way of "performance". It's not doing anything!
|
|
|
|
|
Yes it goes to sleep for 1 minute and reactivates, basically I have to run that ReadFiles() function for every 1 minute, but I want to wait until that function completes, wait for 1 minutes then call that function again.
Here this is serving my purpose but want to check if that's a good practice or will I have any issues going further.
About down votes my friend, its their way of saying things, if somebody asks me a question, I wouldn't put down vote for it, but that's my way of understanding things. I am asking because as I said serving the purpose is not the only aim I have if I can do something better, I wanted to know.
Thanks for saying me this my friend.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Your question has nothing to do with the .NET framework.
Your question has nothing to do with threads. Your program has one thread and you are forcing it to do nothing which is no way performant.
indian143 wrote: Windows Service or Scheduled Task
Which indicates that you have no idea what a Windows Service or Scheduled Task is for. This is exactly what those projects are for.
Speed of sound - 1100 ft/sec
Speed of light - 186,000 mi/sec
Speed of stupid - instantaneous.
|
|
|
|
|
Okay, all you are doing here is putting the main thread to sleep. As designs go, that tends to be really poor.
This space for rent
|
|
|
|
|
Yeah I am putting it into sleep for 1 minute, then it activates again, I know about windows service and task schedulers, but every time putting them on the server involves deployment. This is just copy the files and right click and run as administrator.
My worry Pete does it (Thread sleeping) take lot of resources, but actually its serving my purpose, only question I have is if it takes lot of resources then I will go for the Windows Service or Task Scheduler.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 17-Jan-17 2:57am.
|
|
|
|
|
Putting a thread to sleep doesn't take much in the way of resources - what it does do though is make the thread unresponsive to external stimulation. For a minute, it's unavailable to do anything. There are many suitable constructs you could use that would simplify the task, for instance you could use a Timer. As I work very heavily in RX, I would use RX to manage this but that's just me.
This space for rent
|
|
|
|
|
Thanks Pete, yeah sure I will definitely research about it, can you give me whats full-form of RX? My application is just working fine client is happy too, just its my curiosity to learn and implement good stuff init.
Again thanks for sharing me this information.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
RX is Reactive eXtensions.
This space for rent
|
|
|
|
|
Thank you very much Pete.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
<pre>I create winforms app, and have tabcontroll with some tabpage.In one of then tabpage I have grid.Grid must be have checkbox on the collumns.When I load forms and click on tabpage grid render ok,but when I load forms and select tabpage force grid duplicate collumns,and not checked checkbox?
Its part for render grid, Methode UcitajKontakta.
<pre lang="c#">dbgPacijentKontakt.DataSource = _t;
if (dbgPacijentKontakt.RowCount > 0)
{
for (var i = 0; i < dbgPacijentKontakt.Columns.Count; i++)
{
DataGridViewColumn column = dbgPacijentKontakt.Columns[i];
if (!new[] { "Email rezultati", "Email lab", "Sms podsetnik" }.Contains(column.HeaderText))
{
continue;
}
DataGridViewCheckBoxColumn column1 = new DataGridViewCheckBoxColumn();
column1.HeaderText = column.HeaderText;
column1.Name = column.Name;
column1.CellTemplate = new DataGridViewCheckBoxCell();
dbgPacijentKontakt.Columns.Remove(column);
dbgPacijentKontakt.Columns.Insert(i, column1);
}
dbgPacijentKontakt.CommitEdit(DataGridViewDataErrorContexts.Commit);
for (int i = 0; i < _t.Rows.Count; i++)
{
dbgPacijentKontakt["Sms_podsetnik", i].Value = bool.Parse(_t.Rows[i]["Sms_podsetnik"].ToString());
}
When click on tabpage.
private void tc_SelectedIndexChanged(object sender, EventArgs e)
{
if (tc.SelectedTab == tpKontakti)
{
UcitajKontakta(null);
}
}
This code execute when load forms with predefeni tabpage.
UcitajKontakta(null);
tc.SelectedIndex = tc.TabPages.IndexOf(tpKontakti);
Pls can someone to discribe me what hapend on selecectindexchange event ...
|
|
|
|
|
What? I do not understand your question at all.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Hi,
I am writing an application, where I need to replace only characters after first 3 characters of a string, I can use substring but the we have many scenarios like that where RegEx is going to change for different scenarios, hence I am looking for a common solution to have RegEx stored in a Config and use it depending upon scenario.
Just like in the following string "w00Abdul5998988", I need to replace all but the "w00" characters.
Please help me to either return first three characters of the string or replace all other characters after first 3 characters, any help would be very helpful, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
modified 4-Jan-17 20:34pm.
|
|
|
|
|
string v = stringVariable.Substring(0, 3);
will return the first three characters of the string.
|
|
|
|
|
Yeah I can do it but I have to use regular expression as I have to do it dynamically.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Well can either put the start and length values in your config or you can put a RegEx expression string in your config, just like any other piece of string data.
You really haven't said anything at all that gives enough information about exactly what this RegEx is supposed to do or any other examples of what these "dynamic" situations would be so it's pretty much impossible to tell you anything useful.
|
|
|
|
|
It sounds like you need to create capture groups.
This space for rent
|
|
|
|
|
Thanks to share with us,..I am using your article in my work so thanks to very useful information to share in this article so i am sharing your post.very nice...
|
|
|
|