|
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...
|
|
|
|
|
If your regex is (.{3}).* , then in your replacement string, you can put $1 which is a reference to the (.{3}) group (in this case, w00 ). So, your replacement string will be $1<whatever you want to replace the last part with> .
For example:
string input = "w00Abdul5998988";
string output = Regex.Replace(input, "(.{3}).*", "$1something");
Console.WriteLine(output);
Or if you want to do it with an instance of the Regex object:
Regex re = new Regex("(.{3}).*");
string input = "w00Abdul5998988";
string output = re.Replace(input, "$1something");
Console.WriteLine(output);
The quick brown ProgramFOX jumps right over the Lazy<Dog> .
|
|
|
|
|
I'm learning C# and ASP.Net Core from JavaScript and Node.js. I notice that many classes like
IEnumerable and
IDisposable Are used a lot and seem like you should be familiar with them. What are some other classes and interfaces that pop up often in .Net programming I should be aware of?
i cri evry tiem
|
|
|
|
|
|
The .NET Framework has a lot of classes and which ones you need to know depends a bit on what you want to do, but here are a few ones I'd recommend knowing regardless of what field you want to specialize in:
|
|
|
|
|
Hi all,
I have written a FileSystemWatcher console application, I could able to monitor all changes happening in the folder that's assigned to it and all its SubFolders, if we consider the parent Folder as Root folder, then in our organization there are 10 different root folders where there are going to be at least 200 files are dropped everyday in root folders and sub folders combined.
Hence what I did was I put a table in which admin user can add root folders and start the application then I am using array of FileSystemWatcher and to all these FileSystemWacher objects I am assigning same OnCreated, OnChanged events which in turn are going to call a same function which does only a small thing that's it puts an Entry into Table with FullPath of the file that's dropped with IsProcessed flag false, there's another Application that run different than this and processes those files which are in this Table with flag false and makes the flag to true, anyways my question is not about the second application, but first application that has FileSystemWatcher array.
My question when all those at least 10 different FileSystemWatcher objects assigned with same OnCreated, OnChanged events and in turn those events are calling the same method which is inserting a record into the table, I am worried that can it create any problems in any cases like if files dropped same times or locking etc. But one +ve thing is the method which is being called by the Oncreated and Onchanged events is not doing anything other than simply writing a record, maybe some milliseconds task, the possibility of Files being dropped at the same time even with milliseconds accuracy is minimum.
I am using array of FileSystemWatcher objects to reduce the number of Applications that would be running on the Server, I want to make one Application to start instead of making 10 applications to start.
Please advise me by anyways, a code snippet, a link or even a suggestion would be helpful, thanks in advance my friends.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
200 files a day? That shouldn't be a problem at all.
You have to keep your FileSystemWatcher event handler code execution time as short as possible to avoid buffer overruns in the FSW's. If that means creating a piece of data that another thread picks up to do the actual database processing stuff, so be it. I really wouldn't keep the database code in the event handler because database operations can take longer than expected and cause your FSW's to overrun their buffers, thereby losing changes.
|
|
|
|
|
indian143 wrote: there are 10 different root folders where there are going to be at least 200 files are dropped everyday
I doubt that is significant. Even presuming that you mean 2000 (200 x 10) given a 'day' that means overlaps within the time period of a single database write is very small.
And events can handle more than one at a time (real time) but there are limits.
Given the failure potential is so low it probably isn't worth your time unless you do have the time. If you do have the time or perhaps you have a real concern (based on realistic data) about growth then you can follow the suggestion in the other post.
Basics of what is in the other post.
1. Create a thread safe queue that you can put a request one.
2. Your event handler puts a request on the queue. Your event handler does not interact with the database at all.
3. Create another handler that reads from the queue. It blocks until a request is on the queue. Each request gets written to the queue.
On shut down the application must do the following
1. Shut down the event handler
2. Wait until the queue is empty
3. Exit.
And just to clarify if it really is only 200 a day, your real expectation of growth is low and you do nothing but add a record to the database. And there are no other extenuating circumstances like very poor networks, database is half a world away, etc, then I wouldn't bother spending the time. Between normal business processing, file system overhead, and speed of modern machines it can easily keep up with 200 a day.
You time might be better spent worrying about what happens if your application is not running for a while and then you start it up - how do you resolve what is missing.
|
|
|
|
|
Hi all,
I have an Existing Database, when I use Entityframework DbContext approach I have to write all the classes that are going to be created as Tables in the back-end, but writing all classes is long process, is there anyway I can just create all the classes for my existing database still can use DbContext?
Any help a code snippet, a link or even suggestion is going to be very helpful, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
|
I'm using MVVM that controller side change different database and table value and signalr push notification. So not supporting transactionscope. Any other available in C# code?
|
|
|
|
|
|
Hi,
Since a few days I receive the following error during debugging of my vb.net program.
With this program I setup a connectionstring with a access datebase.
An exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll but was not handled in user code
My program is not changed and when i use the same program on a differtent computer it works.
There I expect it has something to do with windows 10, but I'n not sure.
It always worked before.
As fas as I know I cannot attach any picture otherwise i would have attached a screenshot to this forum.
I hope somebody can help me out.
|
|
|
|