From hans.andersen at phulse.com Sun Apr 1 01:30:17 2012 From: hans.andersen at phulse.com (Hans-Christian Andersen) Date: Sat, 31 Mar 2012 23:30:17 -0700 Subject: [dba-VB] ASP.NET MVC, Web API, Razor and Open Source - ScottGu's Blog In-Reply-To: <4F770406.4030601@colbyconsulting.com> References: <61A1633A-E9E7-4958-B950-5D32011F8F3F@holly.arvixe.com> <4F770406.4030601@colbyconsulting.com> Message-ID: <4FD70F95-662A-47DB-A3B5-AA1D1717A18F@phulse.com> John, > The point however is that developing on / for the web is a mish-mash of technologies which barely play together, all controlled by different factors / companies / standards. I will agree that it is a mish-mash of things, although I don't think I would go as far as to say they barely play together. All software comes with bugs and that is something we've had to deal with since the dawn of time. And you are right in saying that they are not tightly coupled technologies, but that also makes it enormously flexible. I see what your gripe is though, but it is the way it is for a reason and I find it hard to see a better way. You are looking at le Web from the perspective of a traditional application developer, but, bear in mind, building applications on the web is still a work in progress and a recent thing - something that has only been possible by the availability of JS and then XMLHttpRequest (otherwise known as Ajax, which you can thank Microsoft for). Originally HTML was designed to be a way of presenting documents as resources with hyperlinks (and later CSS to decouple the layout and visuals from the actual content). Unlike something like PDF and DOC, which are designed to present documents exactly the same way wherever they are viewed or printed, HTML had to be different because it had to be presented on different devices with different resolutions etc all dependent on where you are consuming that resource from. This is fundamentally what it is and most of what you find on the internet still very much fits this description. I don't mean for this to be a history lesson, but you can clearly see how this differs with WPC and Silverlight, which just wasn't developed for this purpose. Silverlight is more for rich media and such, while WPF is a subsystem for generating graphics. Neither of these are appropriate to replace HTML/CSS/JS. They can't provide you with a semantic web. Now, people have taken HTML/CSS and extended the fundamental web architecture/language in order to develop richer applications by incorporating JS. This has meant they had to push the limits of the technology, but everyone agreed that it had to be open and based on agreed standards, so that no single entity could control the web in a unilateral way or to avoid a fragmentation of the web. This makes the web multilateral, which is always a bit of a messier, but I personally think it has worked out remarkably well and we have all benefitted from this enormously. Honestly, I think what a lot of people might not be so keen on is the fact that they have spent a lot of time learning to develop applications with Microsoft technologies - some starting with VB or C++ MFC/Win32 (as was my case) then onto .NET and then etc. - and then found themselves in the position where they have had to catch up with Javascript and then server-side languages, like Python/Django, PHP, ASP.NET MVC, Ruby on Rails, Node.js, etc, because everything is heading towards the web nowadays. And, I will admit that this is a much more complicated world, as things are changing rapidly - probably faster than in any other time I can think of - and there are a whole host of different languages/frameworks/etc. However, so long as you got some understanding of HTML/CSS/JS, you can pick your web framework of choice (ie. ASP.NET MVC) and then work from there. You don't have to know everything. Even jQuery does a good job of making JS and DOM so incredibly simple and straightforward in ways it never used to be (plus having excellent support for overcoming quirks in every browser (*cough* IE)). I suppose the point I'm trying to make is that this issue goes far beyond pure convenience for programmers. Things are the way they are because it tries to tackle much larger issues and this is the best solution there is for a many number of reasons. Hans On 2012-03-31, at 6:17 AM, jwcolby wrote: > Hans, > > > This comparison is a bit misleading though, as you have simplified a lot of things into "C# and XAML", while, in the case of ASP.NET MVC > > > I agree with everything you say. The point however is that developing on / for the web is a mish-mash of technologies which barely play together, all controlled by different factors / companies / standards. It is just a stinking mess. > > We need a single environment with a single "language" or the web will always remain the abomination it is today. Say what you will, but .Net is a *huge* advance in programming, allowing a developer to select a language and develop in a common environment (yea yea, in Windows only). > > The best that can be said today is that "the web kinda sorta works, some of the time, in some browsers (and differently in every browser), depending entirely on the skills of the developers in the specific mish-mash of tools that they decide to use, and the testing that they did with the various browsers, and the capabilities of the user's selected browser to deal with said mish-mash of tools". > > Not what I want, and not how I want to develop. > > I'll give you an example. My wife had to investigate phone calls made from our phone by a baby sitter. I wasn't here to help, so she bravely got on the phone with Charter. > > We use Firefox. > > Charter tech support had to change the password because Mary did not know the password I use to manage the account. > > Changing the password did not work. An HOUR later, after trying this that and this other thing, the tech support asked her to switch to Internet Explorer. Badaboom, she is in with a new password. > > What a mess the internet is. > > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > On 3/31/2012 12:44 AM, Hans-Christian Andersen wrote: >> This comparison is a bit misleading though, as you have simplified a lot of things into "C# and XAML", while, in the case of ASP.NET MVC, you have been more explicit. But, in any event, this feels like comparing apples and oranges. Silverlight was not designed to be an markup language designed to be used in the same way that HTML/CSS (and JS) is used. WPF is something else altogether. And ASP.NET MVC should, like any good framework, do a lot of the grunt work for you anyways (at least, I hope it does). >> >> Let's also not forget that SL is a Microsoft technology, which is under their control and effectively forces everyone to use Microsoft tech to build anything. This defeats what has made the web so great. >> >> Hans > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > From jwcolby at colbyconsulting.com Wed Apr 4 09:02:28 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 04 Apr 2012 10:02:28 -0400 Subject: [dba-VB] Thread.sleep Message-ID: <4F7C5474.9010401@colbyconsulting.com> I am baffled by what I am seeing in my threaded program. I start a thread which basically pulls data from SQL Server. It does so then does a thread.sleep(10000) which should sleep for 10000 ms (10 seconds). During the sleep, the processor usage jumps to roughly 25%. That indicates that the sleep enables something else to go bonkers but what is that "something else" and why does it depend on this thread sleeping? I really don't want my app consuming 25% of the processor sleeping. On Google I see this question posted on many venues but no real answer. In fact I decided that what I was really trying to accomplish was provided by a timer class so I am in the process of rewriting my code to use the timer. I did it in one place and it works well, no more do while / thread.sleep for me. I'd still like to know what caused the system to spike CPU usage when the thread was sleeping though. -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From mcp2004 at mail.ru Wed Apr 4 11:41:02 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 04 Apr 2012 20:41:02 +0400 Subject: [dba-VB] =?utf-8?q?Thread=2Esleep?= In-Reply-To: <4F7C5474.9010401@colbyconsulting.com> References: <4F7C5474.9010401@colbyconsulting.com> Message-ID: GC ? Wed, 04 Apr 2012 10:02:28 -0400 ?? jwcolby : > I am baffled by what I am seeing in my threaded program. I start a thread which basically pulls > data from SQL Server. It does so then does a thread.sleep(10000) which should sleep for 10000 ms > (10 seconds). During the sleep, the processor usage jumps to roughly 25%. > > That indicates that the sleep enables something else to go bonkers but what is that "something else" > and why does it depend on this thread sleeping? I really don't want my app consuming 25% of the > processor sleeping. > > On Google I see this question posted on many venues but no real answer. > > In fact I decided that what I was really trying to accomplish was provided by a timer class so I am > in the process of rewriting my code to use the timer. I did it in one place and it works well, no > more do while / thread.sleep for me. > > I'd still like to know what caused the system to spike CPU usage when the thread was sleeping though. > > -- > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Wed Apr 4 14:10:54 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 04 Apr 2012 15:10:54 -0400 Subject: [dba-VB] Thread.sleep In-Reply-To: References: <4F7C5474.9010401@colbyconsulting.com> Message-ID: <4F7C9CBE.4050606@colbyconsulting.com> LOL. GC? What is GC? John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/4/2012 12:41 PM, Salakhetdinov Shamil wrote: > GC ? > > > Wed, 04 Apr 2012 10:02:28 -0400 ?? jwcolby: >> I am baffled by what I am seeing in my threaded program. I start a thread which basically pulls >> data from SQL Server. It does so then does a thread.sleep(10000) which should sleep for 10000 ms >> (10 seconds). During the sleep, the processor usage jumps to roughly 25%. >> >> That indicates that the sleep enables something else to go bonkers but what is that "something else" >> and why does it depend on this thread sleeping? I really don't want my app consuming 25% of the >> processor sleeping. >> >> On Google I see this question posted on many venues but no real answer. >> >> In fact I decided that what I was really trying to accomplish was provided by a timer class so I am >> in the process of rewriting my code to use the timer. I did it in one place and it works well, no >> more do while / thread.sleep for me. >> >> I'd still like to know what caused the system to spike CPU usage when the thread was sleeping though. >> >> -- >> John W. Colby >> Colby Consulting >> >> Reality is what refuses to go away >> when you do not believe in it >> >> _______________________________________________ >> dba-VB mailing list >> dba-VB at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-vb >> http://www.databaseadvisors.com >> >> > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > From davidmcafee at gmail.com Wed Apr 4 14:17:38 2012 From: davidmcafee at gmail.com (David McAfee) Date: Wed, 4 Apr 2012 12:17:38 -0700 Subject: [dba-VB] Thread.sleep In-Reply-To: <4F7C9CBE.4050606@colbyconsulting.com> References: <4F7C5474.9010401@colbyconsulting.com> <4F7C9CBE.4050606@colbyconsulting.com> Message-ID: Garbage Collection, although I think you are being facetious. :) You have stirred up in my head regarding a project that I have out there that seems to cause memory issues on certain computers. I haven't been able to recreate this in my office. I do use sleep as well in several places in that app. Care to share the code that worked for you? Thanks, David On Wed, Apr 4, 2012 at 12:10 PM, jwcolby wrote: > LOL. GC? What is GC? > > > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > On 4/4/2012 12:41 PM, Salakhetdinov Shamil wrote: > >> GC ? >> >> >> Wed, 04 Apr 2012 10:02:28 -0400 ?? jwcolby >> >: >> >>> I am baffled by what I am seeing in my threaded program. I start a >>> thread which basically pulls >>> data from SQL Server. It does so then does a thread.sleep(10000) which >>> should sleep for 10000 ms >>> (10 seconds). During the sleep, the processor usage jumps to roughly >>> 25%. >>> >>> That indicates that the sleep enables something else to go bonkers but >>> what is that "something else" >>> and why does it depend on this thread sleeping? I really don't want my >>> app consuming 25% of the >>> processor sleeping. >>> >>> On Google I see this question posted on many venues but no real answer. >>> >>> In fact I decided that what I was really trying to accomplish was >>> provided by a timer class so I am >>> in the process of rewriting my code to use the timer. I did it in one >>> place and it works well, no >>> more do while / thread.sleep for me. >>> >>> I'd still like to know what caused the system to spike CPU usage when >>> the thread was sleeping though. >>> >>> -- >>> John W. Colby >>> Colby Consulting >>> >>> Reality is what refuses to go away >>> when you do not believe in it >>> >>> ______________________________**_________________ >>> dba-VB mailing list >>> dba-VB at databaseadvisors.com >>> http://databaseadvisors.com/**mailman/listinfo/dba-vb >>> http://www.databaseadvisors.**com >>> >>> >>> >> ______________________________**_________________ >> dba-VB mailing list >> dba-VB at databaseadvisors.com >> http://databaseadvisors.com/**mailman/listinfo/dba-vb >> http://www.databaseadvisors.**com >> >> > ______________________________**_________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-vb > http://www.databaseadvisors.**com > > From mcp2004 at mail.ru Wed Apr 4 14:46:32 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 04 Apr 2012 23:46:32 +0400 Subject: [dba-VB] =?utf-8?q?Thread=2Esleep?= In-Reply-To: <4F7C9CBE.4050606@colbyconsulting.com> References: <4F7C5474.9010401@colbyconsulting.com> <4F7C9CBE.4050606@colbyconsulting.com> Message-ID: Hi John, GC is abbreviation for Garbage Collector. Learning to be concise here :) Thank you. -- Shamil Wed, 04 Apr 2012 15:10:54 -0400 ?? jwcolby : > LOL. GC? What is GC? > > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > On 4/4/2012 12:41 PM, Salakhetdinov Shamil wrote: > > GC ? > > > > > > Wed, 04 Apr 2012 10:02:28 -0400 ?? jwcolby: > >> I am baffled by what I am seeing in my threaded program. I start a thread which basically pulls > >> data from SQL Server. It does so then does a thread.sleep(10000) which should sleep for 10000 ms > >> (10 seconds). During the sleep, the processor usage jumps to roughly 25%. > >> > >> That indicates that the sleep enables something else to go bonkers but what is that "something else" > >> and why does it depend on this thread sleeping? I really don't want my app consuming 25% of the > >> processor sleeping. > >> > >> On Google I see this question posted on many venues but no real answer. > >> > >> In fact I decided that what I was really trying to accomplish was provided by a timer class so I am > >> in the process of rewriting my code to use the timer. I did it in one place and it works well, no > >> more do while / thread.sleep for me. > >> > >> I'd still like to know what caused the system to spike CPU usage when the thread was sleeping though. > >> > >> -- > >> John W. Colby > >> Colby Consulting > >> > >> Reality is what refuses to go away > >> when you do not believe in it > >> > >> _______________________________________________ > >> dba-VB mailing list > >> dba-VB at databaseadvisors.com > >> http://databaseadvisors.com/mailman/listinfo/dba-vb > >> http://www.databaseadvisors.com > >> > >> > > > > _______________________________________________ > > dba-VB mailing list > > dba-VB at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-vb > > http://www.databaseadvisors.com > > > > From jwcolby at colbyconsulting.com Wed Apr 4 17:00:54 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 04 Apr 2012 18:00:54 -0400 Subject: [dba-VB] Thread.sleep In-Reply-To: References: <4F7C5474.9010401@colbyconsulting.com> <4F7C9CBE.4050606@colbyconsulting.com> Message-ID: <4F7CC496.70008@colbyconsulting.com> Interesting theory but it seems unlikely. I switched to running the function on a thread from the timer and this CPU spike no longer occurs John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/4/2012 3:46 PM, Salakhetdinov Shamil wrote: > Hi John, > > GC is abbreviation for Garbage Collector. > Learning to be concise here :) > > Thank you. > > -- Shamil > > > Wed, 04 Apr 2012 15:10:54 -0400 ?? jwcolby: >> LOL. GC? What is GC? >> >> John W. Colby >> Colby Consulting >> >> Reality is what refuses to go away >> when you do not believe in it >> >> On 4/4/2012 12:41 PM, Salakhetdinov Shamil wrote: >>> GC ? >>> >>> >>> Wed, 04 Apr 2012 10:02:28 -0400 ?? jwcolby: >>>> I am baffled by what I am seeing in my threaded program. I start a thread which basically pulls >>>> data from SQL Server. It does so then does a thread.sleep(10000) which should sleep for 10000 ms >>>> (10 seconds). During the sleep, the processor usage jumps to roughly 25%. >>>> >>>> That indicates that the sleep enables something else to go bonkers but what is that "something else" >>>> and why does it depend on this thread sleeping? I really don't want my app consuming 25% of the >>>> processor sleeping. >>>> >>>> On Google I see this question posted on many venues but no real answer. >>>> >>>> In fact I decided that what I was really trying to accomplish was provided by a timer class so I am >>>> in the process of rewriting my code to use the timer. I did it in one place and it works well, no >>>> more do while / thread.sleep for me. >>>> >>>> I'd still like to know what caused the system to spike CPU usage when the thread was sleeping though. >>>> >>>> -- >>>> John W. Colby >>>> Colby Consulting >>>> >>>> Reality is what refuses to go away >>>> when you do not believe in it >>>> >>>> _______________________________________________ >>>> dba-VB mailing list >>>> dba-VB at databaseadvisors.com >>>> http://databaseadvisors.com/mailman/listinfo/dba-vb >>>> http://www.databaseadvisors.com >>>> >>>> >>> >>> _______________________________________________ >>> dba-VB mailing list >>> dba-VB at databaseadvisors.com >>> http://databaseadvisors.com/mailman/listinfo/dba-vb >>> http://www.databaseadvisors.com >>> >> >> > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > From davidmcafee at gmail.com Wed Apr 4 17:16:00 2012 From: davidmcafee at gmail.com (David McAfee) Date: Wed, 4 Apr 2012 15:16:00 -0700 Subject: [dba-VB] Thread.sleep In-Reply-To: References: <4F7C5474.9010401@colbyconsulting.com> <4F7C9CBE.4050606@colbyconsulting.com> Message-ID: Did my message ever come through? On Wed, Apr 4, 2012 at 12:17 PM, David McAfee wrote: > Garbage Collection, although I think you are being facetious. :) > > > You have stirred up in my head regarding a project that I have out there > that seems to cause memory issues on certain computers. > > I haven't been able to recreate this in my office. > > I do use sleep as well in several places in that app. > > Care to share the code that worked for you? > > Thanks, > David > From jwcolby at colbyconsulting.com Wed Apr 4 19:51:03 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 04 Apr 2012 20:51:03 -0400 Subject: [dba-VB] Thread.sleep In-Reply-To: References: <4F7C5474.9010401@colbyconsulting.com> <4F7C9CBE.4050606@colbyconsulting.com> Message-ID: <4F7CEC77.7020806@colbyconsulting.com> >> Care to share the code that worked for you? LOL. Sure. I am finishing up troubleshooting / debugging my RunState class. I had this class encapsulating a thread and delegates as well as delegates for sinking and handling check boxes and labels. The objective was to have an encapsulated class which handled a check box or button which the user (me) could check to start a process / uncheck to stop a process. That was working just fine, the thread would run whatever process code needed to run in a while loop - While (RunState - runState.Started) { Do whatever needed doing thread.sleep(pSleepTime) } It was during this thread.Sleep() that the processor usage would spike. I had 4 cores in my dev machine (running this code) and all 4 would get busy, the aggregate would be about 25% of the total CPU power. Really strange! I decided that this really would be better handled with a timer class so now I set up a timer and do something like: if (RunState - runState.Started) { Do whatever needed doing } No more thread.sleep() and no more CPU usage spike. I am integrating that into my RunState class so that I (the developer) can decide whether the RunState should just run code on the calling thread (no thread object), start a thread object based in clsRunState, or start a timer in clsRunState. It is coming back up and I have rewritten my code in two places (so far) which used that while () { dosomething; thread.sleep(pSleepTime); } construct to now use a timer. The timer.Interval is the same value as the pSleepTime, IOW instead of sleeping a thread for 10 seconds I fire a timer every 10 seconds. Basically I am just doing things like checking whether I have a supervisor record ready to process, whether I have any new supervisor records etc. The timer is much cleaner (kinda) and one real upside is that the system is not waiting for the sleep to finish. Anyway, I will post the clsRunstate code I suppose if people promise not to laugh. I am still very much a junior C# programmer. John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/4/2012 6:16 PM, David McAfee wrote: > Did my message ever come through? > > On Wed, Apr 4, 2012 at 12:17 PM, David McAfee wrote: > >> Garbage Collection, although I think you are being facetious. :) >> >> >> You have stirred up in my head regarding a project that I have out there >> that seems to cause memory issues on certain computers. >> >> I haven't been able to recreate this in my office. >> >> I do use sleep as well in several places in that app. >> >> Care to share the code that worked for you? >> >> Thanks, >> David >> > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Wed Apr 4 20:09:14 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 04 Apr 2012 21:09:14 -0400 Subject: [dba-VB] clsRunState - uses thread, timer, delegates etc. - Part 1 In-Reply-To: References: <4F7C5474.9010401@colbyconsulting.com> <4F7C9CBE.4050606@colbyconsulting.com> Message-ID: <4F7CF0BA.6000607@colbyconsulting.com> If anybody actually tries to understand this please respond on this message thread and I will explain my reasoning (or lack thereof). jwc using System; using System.Drawing; using System.Threading; using System.Timers; using System.Windows.Forms; namespace projAccuzip2 { /// RunState /// RunState enum. /// These are the 4 different states that are used by our runState class. /// public enum RunState { Stopping, Stopped, Starting, Started } /// clsRunState /// The parent is the object that has an instance of this class /// The grandparent if the object that owns the parent /// /// clsRunState is instantiated once by the parent object (the parent of clsRunState) /// The grandparent typically owns instances of the parent class /// /// The grandparent calls mStart and mStop to tell the parent that it needs to start or stop /// Each of these methods sets the associated flag and raises an event evStart or evStop /// /// The grandparent calls pRunState to get the current runstate of the Parent object /// The grandparent should never directly set the runstate. Only the parent object knows /// when it transitions from one state to another /// /// The parent can sink the evStart and / or evStop so that it can be immediately notified that /// the grandparent is telling it to start or stop /// /// The parent sets the runstate by calling mSetRunState passing in the run state that it is currently in /// public class clsRunState { #region Header private string rsName = ""; //variable to store the run state name(this name is also used for the thread if there is one) private Thread oThread; //thread object for use by this class if you tell it use it private bool threaded; //variable to track if this class should be threaded private bool threadBusy = false; private System.Timers.Timer timer; private bool timed = false; private bool timerBusy = false; private RunState runState = RunState.Stopped; //A start variable telling everyone the current state of the parent object(defaults to stopped) private CheckBox chkBox; //checkBox control pointer(used to start/stop the runState) private Button btnStartStop; //button control pointer(used to start/stop the runstate) private bool BtnOn = false; //bool variable to track if the button is in the started state or not private string startText = "Start", startingText = "Starting", startedText = "Started...", stopText = "Stop", stoppingText = "Stopping...", stoppedText = "Stopped"; //the different text to display on the checkBox for the different states private Color startingCol = Color.LightGreen, startedCol = Color.DarkGreen, stoppingCol = Color.DarkOrange, stoppedCol = Color.Red; //the different colors to use for the text for the different states public int pTimerInterval { get; set; } /// clsRunState /// Constructor for clsRunState. /// This constructor is used if there is not need to start/stop the class from a form with a checkbox or button. /// /// Name given to this run state class. /// Threaded or not. public clsRunState(string RSName = "", bool Threaded = false, bool Timed = false, int TimerInterval = 10000) { rsName = RSName; //set the name threaded = Threaded; //set the thread variable timed = Timed; pTimerInterval = TimerInterval; InitTimerOrThread(); } /// clsRunState /// Constructor for clsRunState. /// This constructor is used if you want a checkbox on the form for starting and stopping the run state. /// /// Name given to this run state class. /// Checkbox used to start/stopp the run state. /// Threaded or not. public clsRunState(string RSName, CheckBox checkBox, bool Threaded = false, bool Timed = false, int TimerInterval = 10000) { rsName = RSName; //set the name chkBox = checkBox; //set the checkbox pointer chkBox.CheckedChanged += new EventHandler(chkBox_CheckedChanged); //sink the checked event of the checkbox threaded = Threaded; //set the threaded variable timed = Timed; pTimerInterval = TimerInterval; InitTimerOrThread(); } /// clsRunState /// Constructor for clsRunState. /// This constructor is used if you want a button on the form for starting and stopping the run state. /// /// Name given to the run state class. /// Button used to start/stop the run state. /// Threaded or not. public clsRunState(string RSName, Button BtnStartStop, bool Threaded = false, bool Timed = false, int TimerInterval = 10000) { rsName = RSName; //set the name btnStartStop = BtnStartStop; //set the button pointer btnStartStop.Click += new EventHandler(btnStartStop_Click); //sink the click event of the button threaded = Threaded; //set the thread variable timed = Timed; pTimerInterval = TimerInterval; InitTimerOrThread(); } #endregion #region control Delegates //A delegate used to update the check box textColor and text delegate void delUpdateChk (CheckBox chk, Color textColor, string text, bool enabledState); /// /// Performs the invoke to set the checkbox label /// /// /// /// private void invokeChkBox(Color color, string text, bool enabledState) { if (chkBox != null) { lock (chkBox) { chkBox.Invoke(new delUpdateChk(invUpdateChk), new object[] { chkBox, color, text, enabledState }); } } } /// invUpdateLabel /// Delegate method for updating the passed in label color and text. /// /// /// /// private void invUpdateChk(CheckBox chk, Color textColor, string text, bool enabledState) { chk.ForeColor = textColor; //set the checkbox text color chk.Text = text; //set the checkbox text chk.Enabled = enabledState; //set the checkbox enabled property } // A delegate used to update the button enabled state delegate void delUpdateBtn(Button btn, Color textColor, string text, bool enabledState); private void invokeBtn(Color color, string text, bool enabledState) { if (btnStartStop != null) { lock (btnStartStop) { btnStartStop.Invoke(new delUpdateBtn(invUpdateBtn), new object[] { btnStartStop, color, text, enabledState }); } } } /// invUpdateLabel /// Delegate method for updating the button. /// /// /// private void invUpdateBtn(Button btn, Color textColor, string text, bool enabledState) { btn.ForeColor = textColor; //set the button text color btn.Text = text; //set the button text btn.Enabled = enabledState; //set the button enabled property } #endregion #region Timer Delegate /// /// The timer start /// private void timer_Elapsed(object sender, EventArgs e) { if (!timerBusy) //Do not re-enter the code if the timer thread is still busy { timerBusy = true; //Set a flag saying that we are starting the timer thread evTimer(this); //Start the timer thread business. timerBusy = false; //Clear the flag saying the timer thread is busy } } #endregion #region Thread Delegate /// /// The thread start /// /// When running a thread, when we return from the start /// the thread is finished with it's business and will never run again /// If the thread is to run periodically, use the timer /// private void mtStart() { // //Do not allow re-entrant processing. //This should never happen but if it does, //make sure that the code does not re-enter. if (!threadBusy) { threadBusy = true; evStart(this); threadBusy = false; runState = RunState.Stopped; //Set the RunState to stopped } } #endregion #region Events public delegate void delEvStartStop(object sender); public event delEvStartStop evStart; public event delEvStartStop evStop; public delegate void delEvTimer(object sender); public event delEvTimer evTimer; //check box check changed event void chkBox_CheckedChanged(object sender, EventArgs e) { if (chkBox.Checked) //if the checkbox is checked { mStart(); //start the run state } else //else { mStop(); //stop the run state } } //button click event void btnStartStop_Click(object sender, EventArgs e) { if (BtnOn) //if button is on(already started) { mStop(); //stop the run state } else //else { mStart(); //start the run state } } #endregion #region Properties /// pRunState /// Returns the runState. /// public RunState pRunState { get { return runState; } } #endregion John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/4/2012 6:16 PM, David McAfee wrote: > Did my message ever come through? >> >> Care to share the code that worked for you? >> >> Thanks, >> David From jwcolby at colbyconsulting.com Wed Apr 4 20:09:56 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 04 Apr 2012 21:09:56 -0400 Subject: [dba-VB] clsRunState - uses thread, timer, delegates etc. - Part 2 Message-ID: <4F7CF0E4.80503@colbyconsulting.com> Append this to the end of part 1 jwc #region Methods /// InitTimerOrThread /// Initialize the timer or the thread, depending on which (if either) is being used /// called from the class constructor /// private void InitTimerOrThread() { if (threaded) { oThread = new Thread(new ThreadStart(mtStart)); oThread.IsBackground = true; oThread.Name = rsName; } else if (timed) { timer = new System.Timers.Timer(); timer.Interval = pTimerInterval; //Timer fires every N milli-seconds //timer. timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); } } /// mStart /// Call this method to tell the parent of this class to start processing /// and clear the stop flag /// /// Only called by the object asking the parent to start /// public void mStart() { switch (runState) { case RunState.Started: // //If the application is Running then do nothing break; case RunState.Starting: //If the application is Starting then do nothing break; case RunState.Stopped: // //If the application is in the stopped state, then do a start mDoTheStart(); break; case RunState.Stopping: // //The application must call the mStopped event which will set the RunState to Stopped. //and break out of this loop. while (runState == RunState.Stopping) { Application.DoEvents(); } // //When the application finishes stopping, mDoTheStart(); break; } } /// mStarting /// Called by the parent to indicate that we are starting /// (not stopped) /// but not started yet. /// /// If the parent uses this state it MUST call the started method /// or the stop will never process and the system WILL HANG /// /// The Starting and Stopping states allow a little finer granularity /// to the status of the parent process. /// public void mStarting() { runState = RunState.Starting; } /// mStarted /// The parent (application) must call this method to change the runstate to started /// /// !!!Failure to do so will hang the system!!! /// /// public void mStarted() { // //Tell the user that we have started invokeChkBox(startedCol, startedText, true); invokeBtn(startedCol, stopText + " " + rsName, true); //For the button we want to end up with the word "Stop" in the text when it is able to stop the process. // //And set the runstate to started runState = RunState.Started; } /// mDoTheStart /// Updates the checkbox label (if any) /// Sets the RunState to Starting /// /// and raises the start event or /// starts a thread which raises the start event or /// starts a timer which will periodically call its event /// private void mDoTheStart() { invokeChkBox(startingCol, startingText, true); //Tell the user we are starting invokeBtn(startingCol, startingText + " " + rsName, true); //Disable the button runState = RunState.Starting; //Set the RunState to Starting if (threaded) { oThread.Start(); //Using a thread so call the delegate (mtStart) } else if (timed) { evStart(this); //Do the preliminary stuff that has to occur before the timer tick. Some stuff only has to happen once. timer.Start(); //Using a timer so start the timer. This will periodically call the timer's delegate } else { evStart(this); //Not threaded in any way so just do it directly } } /// mStop /// Call this method to tell the parent of this class to stop processing /// and set the stop flag /// /// Only called by the object asking the parent to stop /// public void mStop() { switch (runState) { case RunState.Started: // //The application must be fully up and running mDoTheStop(); break; case RunState.Starting: // //We can't stop in the middle of starting since we will be in an unknown state // //The application must call the mStarted event which will set the RunState to Started //and break out of this loop. while (runState == RunState.Starting) { Application.DoEvents(); } // //Once the application is Started then mDoTheStop(); break; case RunState.Stopped: //The RunState is already stopped so do nothing break; case RunState.Stopping: // //We can't stop (again) in the middle of stopping since we will be in an unknown state // //The application must call the mStopped event which will set the RunState to Stopped. //and break out of this loop. while (runState == RunState.Stopping) { Application.DoEvents(); } break; } } /// mStopping /// Called by the parent to indicate that we are stopping /// (no longer running) /// but not stopped yet /// /// If the parent uses this state it MUST call the started method /// or the stop will never process and the system WILL HANG /// /// The Starting and Stopping states allow a little finer granularity /// to the status of the parent process. /// /// It allows us to say "yes I know I am supposed to stop but I am not finished and can't just shut down right now" /// public void mStopping() { runState = RunState.Stopping; } /// mStopped /// The parent must call this method to change the runstate to stopped /// /// !!!Failure to do so will hang the system!!! /// /// public void mStopped() { try { //Tell the user we have stopped invokeChkBox(stoppedCol, stoppedText, true); // //And set the runstate to stopped runState = RunState.Stopped; } catch (Exception ex) { } } /// mDoTheStop /// Updates the checkbox label (if any) /// Sets the RunState to Stopping /// and raises the stop event /// private void mDoTheStop() { invokeChkBox(stoppingCol, stoppingText, true); //Tell the user we are stopping runState = RunState.Stopping; //Set the RunState to Stopping if (timed) { timer.Stop(); //Using a timer so stop the timer. This will periodically call the timer's delegate } evStop(this); //And call the Stop Event invokeBtn(stoppingCol, startText + " " + rsName, true); //Enable the button } #endregion #region Dispose private bool disposed = false; //Track whether Dispose has been called. ~clsRunState() { Dispose(true); } public void Close() { Dispose(true); // This object will be cleaned up by the Dispose method. // Therefore, you should call GC.SupressFinalize to // take this object off the finalization queue // and prevent finalization code for this object // from executing a second time. GC.SuppressFinalize(this); } // Implement IDisposable. // Do not make this method virtual. // A derived class should not be able to override this method. public void Dispose() { Dispose(true); // This object will be cleaned up by the Dispose method. // Therefore, you should call GC.SupressFinalize to // take this object off the finalization queue // and prevent finalization code for this object // from executing a second time. GC.SuppressFinalize(this); } // Dispose(bool disposing) executes in two distinct scenarios. // If disposing equals true, the method has been called directly // or indirectly by a user's code. Managed and unmanaged resources // can be disposed. // If disposing equals false, the method has been called by the // runtime from inside the finalizer and you should not reference // other objects. Only unmanaged resources can be disposed. private void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this.disposed) { // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { oThread = null; timer = null; } } disposed = true; } #endregion } } -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From mcp2004 at mail.ru Thu Apr 5 04:07:29 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Thu, 05 Apr 2012 13:07:29 +0400 Subject: [dba-VB] =?utf-8?q?Thread=2Esleep?= In-Reply-To: <4F7CC496.70008@colbyconsulting.com> References: <4F7C5474.9010401@colbyconsulting.com> <4F7CC496.70008@colbyconsulting.com> Message-ID: Hi John, That's experience not theory I'm talking here from. And it's very likely you've GC getting busy there when .Sleep(...) is called and your main thread/app is getting suspended. If only you don't have any other processes blocked by your application heavy processor workload while it's active. Do you have your old code preserved? Thank you. -- Shamil Wed, 04 Apr 2012 18:00:54 -0400 ?? jwcolby : > Interesting theory but it seems unlikely. I switched to running the function on a thread from the > timer and this CPU spike no longer occurs > > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > On 4/4/2012 3:46 PM, Salakhetdinov Shamil wrote: > > Hi John, > > > > GC is abbreviation for Garbage Collector. > > Learning to be concise here :) > > > > Thank you. > > > > -- Shamil > > > > > > Wed, 04 Apr 2012 15:10:54 -0400 ?? jwcolby: > >> LOL. GC? What is GC? > >> > >> John W. Colby > >> Colby Consulting > >> > >> Reality is what refuses to go away > >> when you do not believe in it > >> > >> On 4/4/2012 12:41 PM, Salakhetdinov Shamil wrote: > >>> GC ? > >>> > >>> > >>> Wed, 04 Apr 2012 10:02:28 -0400 ?? jwcolby: > >>>> I am baffled by what I am seeing in my threaded program. I start a thread which basically pulls > >>>> data from SQL Server. It does so then does a thread.sleep(10000) which should sleep for 10000 ms > >>>> (10 seconds). During the sleep, the processor usage jumps to roughly 25%. > >>>> > >>>> That indicates that the sleep enables something else to go bonkers but what is that "something else" > >>>> and why does it depend on this thread sleeping? I really don't want my app consuming 25% of the > >>>> processor sleeping. > >>>> > >>>> On Google I see this question posted on many venues but no real answer. > >>>> > >>>> In fact I decided that what I was really trying to accomplish was provided by a timer class so I am > >>>> in the process of rewriting my code to use the timer. I did it in one place and it works well, no > >>>> more do while / thread.sleep for me. > >>>> > >>>> I'd still like to know what caused the system to spike CPU usage when the thread was sleeping though. > >>>> > >>>> -- > >>>> John W. Colby > >>>> Colby Consulting > >>>> > >>>> Reality is what refuses to go away > >>>> when you do not believe in it > >>>> > >>>> _______________________________________________ > >>>> dba-VB mailing list > >>>> dba-VB at databaseadvisors.com > >>>> http://databaseadvisors.com/mailman/listinfo/dba-vb > >>>> http://www.databaseadvisors.com > >>>> > >>>> > >>> > >>> _______________________________________________ > >>> dba-VB mailing list > >>> dba-VB at databaseadvisors.com > >>> http://databaseadvisors.com/mailman/listinfo/dba-vb > >>> http://www.databaseadvisors.com > >>> > >> > >> > > > > _______________________________________________ > > dba-VB mailing list > > dba-VB at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-vb > > http://www.databaseadvisors.com > > > > From mcp2004 at mail.ru Thu Apr 5 04:53:01 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Thu, 05 Apr 2012 13:53:01 +0400 Subject: [dba-VB] =?utf-8?q?Sounds_easy=2E=2E=2E=2E_but_I=27m_a_kind_of_ge?= =?utf-8?q?tting_stuck_here=2E=2E=2E?= Message-ID: Hi All -- I have a DataGridView bound to a DataSet created on MS Access back-end table using built-in into DataSet SQL query. And I need a calculated column to have a value equal to a ([SavedStartDateValue] - DataTime.Today).TotalDays That seems to be not possible to create? I tried to use .PostPaint event to have a value calculated on run-time. It works but DataGridView "flickers". Because of design limitations I can't create a custom query in MS Access back-end db with a calculated field value to be used as binding source for target DataGridView column. I'd be very grateful for any useful for my real programming case advises. TIA, -- Shamil From mcp2004 at mail.ru Thu Apr 5 05:21:46 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Thu, 05 Apr 2012 14:21:46 +0400 Subject: [dba-VB] =?utf-8?q?Sounds_easy=2E=2E=2E=2E_but_I=27m_a_kind_of_ge?= =?utf-8?q?tting_stuck_here=2E=2E=2E?= In-Reply-To: References: Message-ID: > I tried to use .PostPaint event Sorry, I meant .RowPostPaint event... Thank you. -- Shamil Thu, 05 Apr 2012 13:53:01 +0400 ?? Salakhetdinov Shamil : > Hi All -- > > I have a DataGridView bound to a DataSet created on MS Access back-end table using built-in into DataSet SQL query. > And I need a calculated column to have a value equal to a > > ([SavedStartDateValue] - DataTime.Today).TotalDays > > That seems to be not possible to create? > > I tried to use .PostPaint event to have a value calculated on run-time. It works but DataGridView "flickers". > > Because of design limitations I can't create a custom query in MS Access back-end db with a calculated field value to be used as binding source for target DataGridView column. > > I'd be very grateful for any useful for my real programming case advises. > > TIA, > -- Shamil > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From gustav at cactus.dk Thu Apr 5 06:24:27 2012 From: gustav at cactus.dk (Gustav Brock) Date: Thu, 05 Apr 2012 13:24:27 +0200 Subject: [dba-VB] Sounds easy.... but I'm a kind of getting stuck here... Message-ID: Hi Shamil Not possible to create? Are you receiving an error or getting blank results before the RowPostPaint? /gustav >>> Salakhetdinov Shamil 05-04-12 11:53 >>> Hi All -- I have a DataGridView bound to a DataSet created on MS Access back-end table using built-in into DataSet SQL query. And I need a calculated column to have a value equal to a ([SavedStartDateValue] - DataTime.Today).TotalDays That seems to be not possible to create? I tried to use .PostPaint event to have a value calculated on run-time. It works but DataGridView "flickers". Because of design limitations I can't create a custom query in MS Access back-end db with a calculated field value to be used as binding source for target DataGridView column. I'd be very grateful for any useful for my real programming case advises. TIA, -- Shamil From jwcolby at colbyconsulting.com Thu Apr 5 06:30:14 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 05 Apr 2012 07:30:14 -0400 Subject: [dba-VB] Thread.sleep In-Reply-To: References: <4F7C5474.9010401@colbyconsulting.com> <4F7CC496.70008@colbyconsulting.com> Message-ID: <4F7D8246.1010408@colbyconsulting.com> > That's experience not theory I'm talking here from. But the GC should do it's thing and be done. This just sits at ~25% processor utilization forever. And why would the GC not do the same thing if I used the timer. The timer runs the process one time and then the system has control again. GC could run then as well, but there is no 25% processor usage (ever) with the timer model, only when the thread slept. > If only you don't have any other processes blocked by your application heavy processor workload while it's active. While there are times when the processor is heavy duty working, in this case it was not. Basically the thread was reading a recordset from SQL Server and looking at whether the records were in my Supervisor cache, and putting the records in the cache if not. It was literally coasting. The cache was loaded, it was taking milliseconds to do the read and then sleeping for 10 seconds, then doing the read, then sleeping for 10 seconds. During those 10 second sleeps, the processor usage jumped. If the GC were to routinely take 25% of the total CPU power then MS needs to look at that! > Do you have your old code preserved? I do but only as a revision in source control. I have moved on. > That's experience not theory I'm talking here from. So you are saying that you discovered the GC taking a huge chunk of processor cycles without end in one of your apps? John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/5/2012 5:07 AM, Salakhetdinov Shamil wrote: > Hi John, > > That's experience not theory I'm talking here from. > And it's very likely you've GC getting busy there when .Sleep(...) is called and your main thread/app is getting suspended. > If only you don't have any other processes blocked by your application heavy processor workload while it's active. > Do you have your old code preserved? > > Thank you. > > -- Shamil > > > Wed, 04 Apr 2012 18:00:54 -0400 ?? jwcolby: >> Interesting theory but it seems unlikely. I switched to running the function on a thread from the >> timer and this CPU spike no longer occurs >> >> John W. Colby >> Colby Consulting >> >> Reality is what refuses to go away >> when you do not believe in it >> >> On 4/4/2012 3:46 PM, Salakhetdinov Shamil wrote: >>> Hi John, >>> >>> GC is abbreviation for Garbage Collector. >>> Learning to be concise here :) >>> >>> Thank you. >>> >>> -- Shamil >>> >>> >>> Wed, 04 Apr 2012 15:10:54 -0400 ?? jwcolby: >>>> LOL. GC? What is GC? >>>> >>>> John W. Colby >>>> Colby Consulting >>>> >>>> Reality is what refuses to go away >>>> when you do not believe in it >>>> >>>> On 4/4/2012 12:41 PM, Salakhetdinov Shamil wrote: >>>>> GC ? >>>>> >>>>> >>>>> Wed, 04 Apr 2012 10:02:28 -0400 ?? jwcolby: >>>>>> I am baffled by what I am seeing in my threaded program. I start a thread which basically pulls >>>>>> data from SQL Server. It does so then does a thread.sleep(10000) which should sleep for 10000 ms >>>>>> (10 seconds). During the sleep, the processor usage jumps to roughly 25%. >>>>>> >>>>>> That indicates that the sleep enables something else to go bonkers but what is that "something else" >>>>>> and why does it depend on this thread sleeping? I really don't want my app consuming 25% of the >>>>>> processor sleeping. >>>>>> >>>>>> On Google I see this question posted on many venues but no real answer. >>>>>> >>>>>> In fact I decided that what I was really trying to accomplish was provided by a timer class so I am >>>>>> in the process of rewriting my code to use the timer. I did it in one place and it works well, no >>>>>> more do while / thread.sleep for me. >>>>>> >>>>>> I'd still like to know what caused the system to spike CPU usage when the thread was sleeping though. >>>>>> >>>>>> -- >>>>>> John W. Colby >>>>>> Colby Consulting >>>>>> >>>>>> Reality is what refuses to go away >>>>>> when you do not believe in it >>>>>> >>>>>> _______________________________________________ >>>>>> dba-VB mailing list >>>>>> dba-VB at databaseadvisors.com >>>>>> http://databaseadvisors.com/mailman/listinfo/dba-vb >>>>>> http://www.databaseadvisors.com >>>>>> >>>>>> >>>>> >>>>> _______________________________________________ >>>>> dba-VB mailing list >>>>> dba-VB at databaseadvisors.com >>>>> http://databaseadvisors.com/mailman/listinfo/dba-vb >>>>> http://www.databaseadvisors.com >>>>> >>>> >>>> >>> >>> _______________________________________________ >>> dba-VB mailing list >>> dba-VB at databaseadvisors.com >>> http://databaseadvisors.com/mailman/listinfo/dba-vb >>> http://www.databaseadvisors.com >>> >> >> > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > From mcp2004 at mail.ru Thu Apr 5 06:58:44 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Thu, 05 Apr 2012 15:58:44 +0400 Subject: [dba-VB] =?utf-8?q?Thread=2Esleep?= In-Reply-To: <4F7D8246.1010408@colbyconsulting.com> References: <4F7C5474.9010401@colbyconsulting.com> <4F7D8246.1010408@colbyconsulting.com> Message-ID: Hi John -- > So you are saying that you discovered the GC taking a huge chunk of > processor cycles without end in one of your apps? Yes. I have had such trouble in the past in one of the apps I had developed. GC might go "crazy endless looping" sometimes... And you can try googling - there should be information on such a case... You noted that you used delegates/event handlers - they could be "guilty" as they create circular object references, which GC can't drop sometimes - and it "goes nuts" ... When using delegates and/or event handlers, which create circular references always use IDisposable and .Dispose(...) to explicitly clear all circular references otherwise you'll get memory leakage issues and "GC going crazy loops" in the case of heavy load apps... Thank you. -- Shamil Thu, 05 Apr 2012 07:30:14 -0400 ?? jwcolby : > > That's experience not theory I'm talking here from. > > But the GC should do it's thing and be done. This just sits at ~25% processor utilization forever. > And why would the GC not do the same thing if I used the timer. The timer runs the process one > time and then the system has control again. GC could run then as well, but there is no 25% > processor usage (ever) with the timer model, only when the thread slept. > > > If only you don't have any other processes blocked by your application heavy processor workload > while it's active. > > While there are times when the processor is heavy duty working, in this case it was not. Basically > the thread was reading a recordset from SQL Server and looking at whether the records were in my > Supervisor cache, and putting the records in the cache if not. It was literally coasting. The > cache was loaded, it was taking milliseconds to do the read and then sleeping for 10 seconds, then > doing the read, then sleeping for 10 seconds. > > During those 10 second sleeps, the processor usage jumped. If the GC were to routinely take 25% of > the total CPU power then MS needs to look at that! > > > Do you have your old code preserved? > > I do but only as a revision in source control. I have moved on. > > > That's experience not theory I'm talking here from. > > So you are saying that you discovered the GC taking a huge chunk of processor cycles without end in > one of your apps? > > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > On 4/5/2012 5:07 AM, Salakhetdinov Shamil wrote: > > Hi John, > > > > That's experience not theory I'm talking here from. > > And it's very likely you've GC getting busy there when .Sleep(...) is called and your main thread/app is getting suspended. > > If only you don't have any other processes blocked by your application heavy processor workload while it's active. > > Do you have your old code preserved? > > > > Thank you. > > > > -- Shamil > > > > > > Wed, 04 Apr 2012 18:00:54 -0400 ?? jwcolby: > >> Interesting theory but it seems unlikely. I switched to running the function on a thread from the > >> timer and this CPU spike no longer occurs > >> > >> John W. Colby > >> Colby Consulting > >> > >> Reality is what refuses to go away > >> when you do not believe in it > >> > >> On 4/4/2012 3:46 PM, Salakhetdinov Shamil wrote: > >>> Hi John, > >>> > >>> GC is abbreviation for Garbage Collector. > >>> Learning to be concise here :) > >>> > >>> Thank you. > >>> > >>> -- Shamil > >>> > >>> > >>> Wed, 04 Apr 2012 15:10:54 -0400 ?? jwcolby: > >>>> LOL. GC? What is GC? > >>>> > >>>> John W. Colby > >>>> Colby Consulting > >>>> > >>>> Reality is what refuses to go away > >>>> when you do not believe in it > >>>> > >>>> On 4/4/2012 12:41 PM, Salakhetdinov Shamil wrote: > >>>>> GC ? > >>>>> > >>>>> > >>>>> Wed, 04 Apr 2012 10:02:28 -0400 ?? jwcolby: > >>>>>> I am baffled by what I am seeing in my threaded program. I start a thread which basically pulls > >>>>>> data from SQL Server. It does so then does a thread.sleep(10000) which should sleep for 10000 ms > >>>>>> (10 seconds). During the sleep, the processor usage jumps to roughly 25%. > >>>>>> > >>>>>> That indicates that the sleep enables something else to go bonkers but what is that "something else" > >>>>>> and why does it depend on this thread sleeping? I really don't want my app consuming 25% of the > >>>>>> processor sleeping. > >>>>>> > >>>>>> On Google I see this question posted on many venues but no real answer. > >>>>>> > >>>>>> In fact I decided that what I was really trying to accomplish was provided by a timer class so I am > >>>>>> in the process of rewriting my code to use the timer. I did it in one place and it works well, no > >>>>>> more do while / thread.sleep for me. > >>>>>> > >>>>>> I'd still like to know what caused the system to spike CPU usage when the thread was sleeping though. > >>>>>> > >>>>>> -- > >>>>>> John W. Colby > >>>>>> Colby Consulting > >>>>>> > >>>>>> Reality is what refuses to go away > >>>>>> when you do not believe in it > >>>>>> > >>>>>> _______________________________________________ > >>>>>> dba-VB mailing list > >>>>>> dba-VB at databaseadvisors.com > >>>>>> http://databaseadvisors.com/mailman/listinfo/dba-vb > >>>>>> http://www.databaseadvisors.com > >>>>>> > >>>>>> > >>>>> > >>>>> _______________________________________________ > >>>>> dba-VB mailing list > >>>>> dba-VB at databaseadvisors.com > >>>>> http://databaseadvisors.com/mailman/listinfo/dba-vb > >>>>> http://www.databaseadvisors.com > >>>>> > >>>> > >>>> > >>> > >>> _______________________________________________ > >>> dba-VB mailing list > >>> dba-VB at databaseadvisors.com > >>> http://databaseadvisors.com/mailman/listinfo/dba-vb > >>> http://www.databaseadvisors.com > >>> > >> > >> > > > > _______________________________________________ > > dba-VB mailing list > > dba-VB at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-vb > > http://www.databaseadvisors.com > > > > From mcp2004 at mail.ru Thu Apr 5 07:17:19 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Thu, 05 Apr 2012 16:17:19 +0400 Subject: [dba-VB] =?utf-8?q?Sounds_easy=2E=2E=2E=2E_but_I=27m_a_kind_of_ge?= =?utf-8?q?tting_stuck=09here=2E=2E=2E?= In-Reply-To: References: Message-ID: Hi Gustav -- Setting cell value in.RowPostPaint works well, but DataGridView is flickering a bit... > Not possible to create? I meant I can't create a calculated column with a formula as e.g. ([SavedStartDateValue] - DataTime.Today).TotalDays Never used that "complex" calculated columns before. The set of possible calculated columns expressions seems to be very limited - http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx I have also tried to use unbound column and to set its value in .RowPostPaint event - that worked well, DataGridView flickering disappeared but in this case automatic sorting of DataGridView by unbound column isn't working. Implementation of manual (custom code driven) sorting seems to be not right way to go as it would be laborious and it would relatively slow comparing to bound columns sorting: the source dataset has more than 10000 rows and the quantity of rows will grow with time - that is a customer requirement... So I decided to give-up and to get column values calculated in a back-end MS Access database query... Do you expect there could be an effective solution for my case without using calculated columns created in MS Access back-end queries? Thank you. -- Shamil Thu, 05 Apr 2012 13:24:27 +0200 ?? "Gustav Brock" : > Hi Shamil > > Not possible to create? > > Are you receiving an error or getting blank results before the RowPostPaint? > > /gustav > > > >>> Salakhetdinov Shamil 05-04-12 11:53 >>> > Hi All -- > > I have a DataGridView bound to a DataSet created on MS Access back-end table using built-in into DataSet SQL query. > And I need a calculated column to have a value equal to a > > ([SavedStartDateValue] - DataTime.Today).TotalDays > > That seems to be not possible to create? > > I tried to use .PostPaint event to have a value calculated on run-time. It works but DataGridView "flickers". > > Because of design limitations I can't create a custom query in MS Access back-end db with a calculated field value to be used as binding source for target DataGridView column. > > I'd be very grateful for any useful for my real programming case advises. > > TIA, > -- Shamil > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From fuller.artful at gmail.com Thu Apr 5 07:33:48 2012 From: fuller.artful at gmail.com (Arthur Fuller) Date: Thu, 5 Apr 2012 08:33:48 -0400 Subject: [dba-VB] clsRunState - uses thread, timer, delegates etc. - Part 2 In-Reply-To: <4F7CF0E4.80503@colbyconsulting.com> References: <4F7CF0E4.80503@colbyconsulting.com> Message-ID: Thanks, JC. Tutorials are most welcome to this C# newbie. One curious thing, regarding your opening remarks. "I will explain my reasoning (or lack thereof)." How does one explain one's lack of reasoning? If you figure that out, perhaps there's a place for you in Rick Santorum's campaign :) A. From jwcolby at colbyconsulting.com Thu Apr 5 07:44:22 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 05 Apr 2012 08:44:22 -0400 Subject: [dba-VB] clsRunState - uses thread, timer, delegates etc. - Part 2 In-Reply-To: References: <4F7CF0E4.80503@colbyconsulting.com> Message-ID: <4F7D93A6.5080005@colbyconsulting.com> >>How does one explain one's lack of reasoning? There are many explanations for lack of reasoning... >>If you figure that out, perhaps there's a place for you in Rick Santorum's campaign :) ROTFL. In the case of the Republican party, it is not so much lack of reasoning as lack of empathy. John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/5/2012 8:33 AM, Arthur Fuller wrote: > Thanks, JC. Tutorials are most welcome to this C# newbie. > > One curious thing, regarding your opening remarks. "I will explain my > reasoning (or lack thereof)." How does one explain one's lack of reasoning? > If you figure that out, perhaps there's a place for you in Rick Santorum's > campaign :) > > A. > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From gustav at cactus.dk Thu Apr 5 08:20:48 2012 From: gustav at cactus.dk (Gustav Brock) Date: Thu, 05 Apr 2012 15:20:48 +0200 Subject: [dba-VB] Sounds easy.... but I'm a kind of getting stuck here... Message-ID: Hi Shamil OK, seems like you are limited to basic expressions as in the report viewer. So your expression could look like: Date() - [SavedStartDateValue] but I doubt Date() is at your disposal. Anyway, you should be able to sort on [SavedStartDateValue] and not the days' count. Don't know if a saved query will do ... does it support functions Of VBA like Date()? /gustav >>> Salakhetdinov Shamil 05-04-12 14:17 >>> Hi Gustav -- Setting cell value in.RowPostPaint works well, but DataGridView is flickering a bit... > Not possible to create? I meant I can't create a calculated column with a formula as e.g. ([SavedStartDateValue] - DataTime.Today).TotalDays Never used that "complex" calculated columns before. The set of possible calculated columns expressions seems to be very limited - http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx I have also tried to use unbound column and to set its value in .RowPostPaint event - that worked well, DataGridView flickering disappeared but in this case automatic sorting of DataGridView by unbound column isn't working. Implementation of manual (custom code driven) sorting seems to be not right way to go as it would be laborious and it would relatively slow comparing to bound columns sorting: the source dataset has more than 10000 rows and the quantity of rows will grow with time - that is a customer requirement... So I decided to give-up and to get column values calculated in a back-end MS Access database query... Do you expect there could be an effective solution for my case without using calculated columns created in MS Access back-end queries? Thank you. -- Shamil Thu, 05 Apr 2012 13:24:27 +0200 ?? "Gustav Brock" : > Hi Shamil > > Not possible to create? > > Are you receiving an error or getting blank results before the RowPostPaint? > > /gustav > > > >>> Salakhetdinov Shamil 05-04-12 11:53 >>> > Hi All -- > > I have a DataGridView bound to a DataSet created on MS Access back-end table using built-in into DataSet SQL query. > And I need a calculated column to have a value equal to a > > ([SavedStartDateValue] - DataTime.Today).TotalDays > > That seems to be not possible to create? > > I tried to use .PostPaint event to have a value calculated on run-time. It works but DataGridView "flickers". > > Because of design limitations I can't create a custom query in MS Access back-end db with a calculated field value to be used as binding source for target DataGridView column. > > I'd be very grateful for any useful for my real programming case advises. > > TIA, > -- Shamil From mcp2004 at mail.ru Thu Apr 5 08:44:28 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Thu, 05 Apr 2012 17:44:28 +0400 Subject: [dba-VB] =?utf-8?q?Sounds_easy=2E=2E=2E=2E_but_I=27m_a_kind_of_ge?= =?utf-8?b?dHRpbmcJc3R1Y2sJaGVyZS4uLg==?= In-Reply-To: References: Message-ID: Hi Gustav -- Yes, you can use built-in VBA functions in MS Access backend saved queries and run that queries from within your .NET apps - MS Jet Engine "is aware" of VBA. > Date() - [SavedStartDateValue] > but I doubt Date() is at your disposal. It isn't - ADO.NET DataSets calculated columns expressions are very limited. Thank you. -- Shamil Thu, 05 Apr 2012 15:20:48 +0200 ?? "Gustav Brock" : > Hi Shamil > > OK, seems like you are limited to basic expressions as in the report viewer. > > So your expression could look like: > > Date() - [SavedStartDateValue] > > but I doubt Date() is at your disposal. > Anyway, you should be able to sort on [SavedStartDateValue] and not the days' count. > > Don't know if a saved query will do ... does it support functions Of VBA like Date()? > > /gustav > > > >>> Salakhetdinov Shamil 05-04-12 14:17 >>> > Hi Gustav -- > > Setting cell value in.RowPostPaint works well, but DataGridView is flickering a bit... > > > Not possible to create? > I meant I can't create a calculated column with a formula as e.g. > > ([SavedStartDateValue] - DataTime.Today).TotalDays > > Never used that "complex" calculated columns before. > The set of possible calculated columns expressions seems to be very limited - http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx > > I have also tried to use unbound column and to set its value in .RowPostPaint event - that worked well, DataGridView flickering disappeared but in this case automatic sorting of DataGridView by unbound column isn't working. > Implementation of manual (custom code driven) sorting seems to be not right way to go as it would be laborious and it would relatively slow comparing to bound columns sorting: the source dataset has more than 10000 rows and the quantity of rows will grow with time - that is a customer requirement... > > So I decided to give-up and to get column values calculated in a back-end MS Access database query... > > Do you expect there could be an effective solution for my case without using calculated columns created in MS Access back-end queries? > > Thank you. > > -- Shamil > > > > Thu, 05 Apr 2012 13:24:27 +0200 ?? "Gustav Brock" : > > Hi Shamil > > > > Not possible to create? > > > > Are you receiving an error or getting blank results before the RowPostPaint? > > > > /gustav > > > > > > >>> Salakhetdinov Shamil 05-04-12 11:53 >>> > > Hi All -- > > > > I have a DataGridView bound to a DataSet created on MS Access back-end table using built-in into DataSet SQL query. > > And I need a calculated column to have a value equal to a > > > > ([SavedStartDateValue] - DataTime.Today).TotalDays > > > > That seems to be not possible to create? > > > > I tried to use .PostPaint event to have a value calculated on run-time. It works but DataGridView "flickers". > > > > Because of design limitations I can't create a custom query in MS Access back-end db with a calculated field value to be used as binding source for target DataGridView column. > > > > I'd be very grateful for any useful for my real programming case advises. > > > > TIA, > > -- Shamil > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From gustav at cactus.dk Thu Apr 5 09:03:15 2012 From: gustav at cactus.dk (Gustav Brock) Date: Thu, 05 Apr 2012 16:03:15 +0200 Subject: [dba-VB] Sounds easy.... but I'm a kind of getting stuck here... Message-ID: Hi Shamil OK, then the saved query of Access seems to be the solution. I didn't know that was possible. /gustav >>> Salakhetdinov Shamil 05-04-12 15:44 >>> Hi Gustav -- Yes, you can use built-in VBA functions in MS Access backend saved queries and run that queries from within your .NET apps - MS Jet Engine "is aware" of VBA. > Date() - [SavedStartDateValue] > but I doubt Date() is at your disposal. It isn't - ADO.NET DataSets calculated columns expressions are very limited. Thank you. -- Shamil Thu, 05 Apr 2012 15:20:48 +0200 ?? "Gustav Brock" : > Hi Shamil > > OK, seems like you are limited to basic expressions as in the report viewer. > > So your expression could look like: > > Date() - [SavedStartDateValue] > > but I doubt Date() is at your disposal. > Anyway, you should be able to sort on [SavedStartDateValue] and not the days' count. > > Don't know if a saved query will do ... does it support functions Of VBA like Date()? > > /gustav > > > >>> Salakhetdinov Shamil 05-04-12 14:17 >>> > Hi Gustav -- > > Setting cell value in.RowPostPaint works well, but DataGridView is flickering a bit... > > > Not possible to create? > I meant I can't create a calculated column with a formula as e.g. > > ([SavedStartDateValue] - DataTime.Today).TotalDays > > Never used that "complex" calculated columns before. > The set of possible calculated columns expressions seems to be very limited - http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx > > I have also tried to use unbound column and to set its value in .RowPostPaint event - that worked well, DataGridView flickering disappeared but in this case automatic sorting of DataGridView by unbound column isn't working. > Implementation of manual (custom code driven) sorting seems to be not right way to go as it would be laborious and it would relatively slow comparing to bound columns sorting: the source dataset has more than 10000 rows and the quantity of rows will grow with time - that is a customer requirement... > > So I decided to give-up and to get column values calculated in a back-end MS Access database query... > > Do you expect there could be an effective solution for my case without using calculated columns created in MS Access back-end queries? > > Thank you. > > -- Shamil From rls at WeBeDb.com Thu Apr 5 12:46:35 2012 From: rls at WeBeDb.com (Robert Stewart) Date: Thu, 05 Apr 2012 12:46:35 -0500 Subject: [dba-VB] clsRunState - uses thread, timer, delegates etc In-Reply-To: References: Message-ID: Or as the next Democratic nominee for president. (depending on your political leanings) At 07:33 AM 4/5/2012, you wrote: >Date: Thu, 5 Apr 2012 08:33:48 -0400 >From: Arthur Fuller >To: "Discussion concerning Visual Basic and related programming > issues." >Subject: Re: [dba-VB] clsRunState - uses thread, timer, delegates etc. > - Part 2 >Message-ID: > >Content-Type: text/plain; charset=ISO-8859-1 > >Thanks, JC. Tutorials are most welcome to this C# newbie. > >One curious thing, regarding your opening remarks. "I will explain my >reasoning (or lack thereof)." How does one explain one's lack of reasoning? >If you figure that out, perhaps there's a place for you in Rick Santorum's >campaign :) > >A. Robert L. Stewart www.WeBeDb.com www.DBGUIDesign.com www.RLStewartPhotography.com From mcp2004 at mail.ru Thu Apr 5 16:58:34 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Fri, 06 Apr 2012 01:58:34 +0400 Subject: [dba-VB] =?utf-8?q?Sounds_easy=2E=2E=2E=2E_but_I=27m_a_kind_of_ge?= =?utf-8?q?tting_stuck=09here=2E=2E=2E?= In-Reply-To: References: Message-ID: Hi Gustav -- > I didn't know that was possible. Yes, you can create queries in an MS Access back-end which use built-in VBA functions and run that queries from within your C# apps. I do not know exactly what subset of built-in VBA functions can be used in saved queries. So far I have only used IIF, ISNULL and DATEDIFF... You can also run dynamic SQL queries built in C# on run-time, which have built-in VBA functions... AFAIU MS Jet Engine does call/interpret built-in VBA functions while processing a saved or dynamic query... You can also use IN clause in C# OleDb queries' text , e.g., to have tables from several MS Access databases joined... Thank you. -- Shamil Thu, 05 Apr 2012 16:03:15 +0200 ?? "Gustav Brock" : > Hi Shamil > > OK, then the saved query of Access seems to be the solution. > I didn't know that was possible. > > /gustav > > > >>> Salakhetdinov Shamil 05-04-12 15:44 >>> > Hi Gustav -- > > Yes, you can use built-in VBA functions in MS Access backend saved queries and run that queries from within your .NET apps - MS Jet Engine "is aware" of VBA. > > > Date() - [SavedStartDateValue] > > but I doubt Date() is at your disposal. > It isn't - ADO.NET DataSets calculated columns expressions are very limited. > > Thank you. > > -- Shamil > > > Thu, 05 Apr 2012 15:20:48 +0200 ?? "Gustav Brock" : > > Hi Shamil > > > > OK, seems like you are limited to basic expressions as in the report viewer. > > > > So your expression could look like: > > > > Date() - [SavedStartDateValue] > > > > but I doubt Date() is at your disposal. > > Anyway, you should be able to sort on [SavedStartDateValue] and not the days' count. > > > > Don't know if a saved query will do ... does it support functions Of VBA like Date()? > > > > /gustav > > > > > > >>> Salakhetdinov Shamil 05-04-12 14:17 >>> > > Hi Gustav -- > > > > Setting cell value in.RowPostPaint works well, but DataGridView is flickering a bit... > > > > > Not possible to create? > > I meant I can't create a calculated column with a formula as e.g. > > > > ([SavedStartDateValue] - DataTime.Today).TotalDays > > > > Never used that "complex" calculated columns before. > > The set of possible calculated columns expressions seems to be very limited - http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx > > > > I have also tried to use unbound column and to set its value in .RowPostPaint event - that worked well, DataGridView flickering disappeared but in this case automatic sorting of DataGridView by unbound column isn't working. > > Implementation of manual (custom code driven) sorting seems to be not right way to go as it would be laborious and it would relatively slow comparing to bound columns sorting: the source dataset has more than 10000 rows and the quantity of rows will grow with time - that is a customer requirement... > > > > So I decided to give-up and to get column values calculated in a back-end MS Access database query... > > > > Do you expect there could be an effective solution for my case without using calculated columns created in MS Access back-end queries? > > > > Thank you. > > > > -- Shamil > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From mcp2004 at mail.ru Tue Apr 10 16:50:40 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 11 Apr 2012 01:50:40 +0400 Subject: [dba-VB] =?utf-8?q?fast-member_-_a_=2EDLR_magic_=28I=27m_still_pl?= =?utf-8?q?anning_to_try_to_understand_how_it_works=2E=2E=2E=29?= Message-ID: fyi: http://code.google.com/p/fast-member/ -ss From Gustav at cactus.dk Wed Apr 11 00:56:48 2012 From: Gustav at cactus.dk (Gustav Brock) Date: Wed, 11 Apr 2012 07:56:48 +0200 Subject: [dba-VB] fast-member - a .DLR magic (I'm still planning to try to understand how it works...) Message-ID: Hi Shamil I think I understand the syntax - and the purpose (to name variables at runtime, right?) - but I wouldn't know a practical use for it, at least never have had the need, except once in VBA where I just created a Select .. Case block to handle it. Or am I missing something? /gustav >>> Salakhetdinov Shamil 10-04-2012 23:50 >>> fyi: http://code.google.com/p/fast-member/ -ss From mcp2004 at mail.ru Wed Apr 11 13:37:45 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 11 Apr 2012 22:37:45 +0400 Subject: [dba-VB] =?utf-8?q?fast-member_-_a_=2EDLR_magic_=28I=27m_still_pl?= =?utf-8?q?anning_to=09try_to_understand_how_it_works=2E=2E=2E=29?= In-Reply-To: References: Message-ID: HI Gustav -- It can be used e.g. in ORM systems to dynamically map/bind data rows to POCOs. Yes, I too understand the syntax etc. - but I have never used most of .NET Framework classes used in http://code.google.com/p/fast-member/ -- Shamil Wed, 11 Apr 2012 07:56:48 +0200 ?? "Gustav Brock" : > Hi Shamil > > I think I understand the syntax - and the purpose (to name variables at runtime, right?) - but I wouldn't know a practical use for it, at least never have had the need, except once in VBA where I just created a Select .. Case block to handle it. Or am I missing something? > > /gustav > > > >>> Salakhetdinov Shamil 10-04-2012 23:50 >>> > fyi: http://code.google.com/p/fast-member/ > > -ss > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From Gustav at cactus.dk Thu Apr 12 02:11:46 2012 From: Gustav at cactus.dk (Gustav Brock) Date: Thu, 12 Apr 2012 09:11:46 +0200 Subject: [dba-VB] fast-member - a .DLR magic (I'm still planning to try to understand how it works...) Message-ID: Hi Shamil OK, that's an example. But I don't do custom ORM ... I'll mark the link should I ever have the need. /gustav >>> Salakhetdinov Shamil 11-04-2012 20:37 >>> HI Gustav -- It can be used e.g. in ORM systems to dynamically map/bind data rows to POCOs. Yes, I too understand the syntax etc. - but I have never used most of .NET Framework classes used in http://code.google.com/p/fast-member/ -- Shamil Wed, 11 Apr 2012 07:56:48 +0200 ?? "Gustav Brock" : > Hi Shamil > > I think I understand the syntax - and the purpose (to name variables at runtime, right?) - but I wouldn't know a practical use for it, at least never have had the need, except once in VBA where I just created a Select .. Case block to handle it. Or am I missing something? > > /gustav > > > >>> Salakhetdinov Shamil 10-04-2012 23:50 >>> > fyi: http://code.google.com/p/fast-member/ > > -ss From mcp2004 at mail.ru Thu Apr 12 04:44:52 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Thu, 12 Apr 2012 13:44:52 +0400 Subject: [dba-VB] =?utf-8?q?fast-member_-_a_=2EDLR_magic_=28I=27m_still_pl?= =?utf-8?q?anning_to=09try_to_understand_how_it_works=2E=2E=2E=29?= In-Reply-To: References: Message-ID: Hi Gustav -- > OK, that's an example. But I don't do custom ORM ... Never say never ;) Another example could be a "generic" (CSV/) text files reader/writer... I'd advise to "steal" the code as it may happen the link will become broken with time... Thank you. -- Shamil Thu, 12 Apr 2012 09:11:46 +0200 ?? "Gustav Brock" : > Hi Shamil > > OK, that's an example. But I don't do custom ORM ... > > I'll mark the link should I ever have the need. > > /gustav > > > >>> Salakhetdinov Shamil 11-04-2012 20:37 >>> > HI Gustav -- > > It can be used e.g. in ORM systems to dynamically map/bind data rows to POCOs. > > Yes, I too understand the syntax etc. - but I have never used most of .NET Framework classes used in http://code.google.com/p/fast-member/ > > -- Shamil > > > Wed, 11 Apr 2012 07:56:48 +0200 ?? "Gustav Brock" : > > Hi Shamil > > > > I think I understand the syntax - and the purpose (to name variables at runtime, right?) - but I wouldn't know a practical use for it, at least never have had the need, except once in VBA where I just created a Select .. Case block to handle it. Or am I missing something? > > > > /gustav > > > > > > >>> Salakhetdinov Shamil 10-04-2012 23:50 >>> > > fyi: http://code.google.com/p/fast-member/ > > > > -ss > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Thu Apr 12 09:23:45 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 12 Apr 2012 10:23:45 -0400 Subject: [dba-VB] Just looking for a consensus Message-ID: <4F86E571.5040608@colbyconsulting.com> I have pairs of flags and methods to set/get those flags, an Err and ErrMsg. Err is the date/time and ErrMsg is the message. It seems appropriate to call Err from ErrMsg, i.e. if I set an error message, have that property call the Err property to set the date / time as well. As it is I call two properties, one to set the date / time and the other to save the error message. Your thoughts? -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From mcp2004 at mail.ru Fri Apr 13 06:17:21 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Fri, 13 Apr 2012 15:17:21 +0400 Subject: [dba-VB] =?utf-8?q?Just_looking_for_a_consensus?= In-Reply-To: <4F86E571.5040608@colbyconsulting.com> References: <4F86E571.5040608@colbyconsulting.com> Message-ID: Hi John -- > Your thoughts? Not mine actually, but I'm trying to follow the same principles/approach in my everyday software development work: ?The cleanest solution with the fewest moving parts as possible". (Source: http://techcrunch.com/2012/04/12/how-to-scale-a-1-billion-startup-a-guide-from-instagram-co-founder-mike-krieger/?grcc=33333Z98ZtrendingZ0 ) Applied for you case I'd write today (tomorrow I could write it differently - depending on tomorrow's context): public DateTime Err { get; private set; } public string ErrMsg { get; private set; } public void SetErrorInfo(string errMsg, DateTime? errorTimeStamp = null) { this.Err = errorTimeStamp??DateTime.Now; this.ErrMsg = errMsg; } or public ErrInfo() { } public DateTime Err { get; private set; } public string ErrMsg { get; private set; } public ErrInfo SetErrorInfo(string errMsg, DateTime? errorTimeStamp = null) { this.Err = errorTimeStamp??DateTime.Now; this.ErrMsg = errMsg; return this; } The latter code can be used to create error information object and to set its properties in one code line: ErrInfo err = (new ErrInfo()).SetErrorInfo("My Error information"); or ErrInfo err = (new ErrInfo()).SetErrorInfo("My Error information", new DateTime(2012,1,3)); And I do not expect to get into consensus for this solution here ;) Thank you. -- Shamil Thu, 12 Apr 2012 10:23:45 -0400 ?? jwcolby : > I have pairs of flags and methods to set/get those flags, an Err and ErrMsg. Err is the date/time > and ErrMsg is the message. > > It seems appropriate to call Err from ErrMsg, i.e. if I set an error message, have that property > call the Err property to set the date / time as well. > > As it is I call two properties, one to set the date / time and the other to save the error message. > > Your thoughts? > > -- > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Fri Apr 13 08:14:03 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Fri, 13 Apr 2012 09:14:03 -0400 Subject: [dba-VB] Just looking for a consensus In-Reply-To: References: <4F86E571.5040608@colbyconsulting.com> Message-ID: <4F88269B.6080307@colbyconsulting.com> Thanks Shamil, I have a class which I call clsFlag which allows me to write to the flag and the flag writes through to SQL Server. In fact the Flag handles several data types but it allows me to initialize it such that I can write a boolean and the flag class translates that into now() - this instant date / time which is what gets written to SQL Server. When it reads a data it translates any date value other than the framework's "mindate to a true and minDate to a false. Thus these actual values (flags) in SQL Server is always a date but to my program they are a bool (for decision making). I have a pair of classes (Supervisor and Process which have just a ton of fields written to asynchronously by processes occurring as I validate addresses. clsSupervisor and clsProcess load these records (the flag fields) into instances of these flag classes which are then stored in a collection in clsFlagSupervisor. Thus as clsSupervisor or clsProcess do anything they can just update their flag and the flag writes it through to SQL Server. I designed the error flags to be a pair of fields - an ErrDate and a ErrMsg varchar(4000). I was writing to the ErrMsg flag and then the ErrDate flag. I have refactored the properties which handle the message to call through to the associated ErrDate property to set the ErrDate if I write to the ErrMsg property. That is done in clsSupervisor and clsProcess though, where I define these properties. John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/13/2012 7:17 AM, Salakhetdinov Shamil wrote: > Hi John -- > >> Your thoughts? > Not mine actually, but I'm trying to follow the same principles/approach in my everyday software development work: > > ?The cleanest solution with the fewest moving parts as possible". > > (Source: http://techcrunch.com/2012/04/12/how-to-scale-a-1-billion-startup-a-guide-from-instagram-co-founder-mike-krieger/?grcc=33333Z98ZtrendingZ0 ) > > Applied for you case I'd write today (tomorrow I could write it differently - depending on tomorrow's context): > > public DateTime Err { get; private set; } > public string ErrMsg { get; private set; } > public void SetErrorInfo(string errMsg, DateTime? errorTimeStamp = null) > { > this.Err = errorTimeStamp??DateTime.Now; > this.ErrMsg = errMsg; > } > > or > > public ErrInfo() { } > public DateTime Err { get; private set; } > public string ErrMsg { get; private set; } > public ErrInfo SetErrorInfo(string errMsg, DateTime? errorTimeStamp = null) > { > this.Err = errorTimeStamp??DateTime.Now; > this.ErrMsg = errMsg; > return this; > } > > The latter code can be used to create error information object and to set its properties in one code line: > > ErrInfo err = (new ErrInfo()).SetErrorInfo("My Error information"); > > or > > ErrInfo err = (new ErrInfo()).SetErrorInfo("My Error information", new DateTime(2012,1,3)); > > > And I do not expect to get into consensus for this solution here ;) > > Thank you. > > -- Shamil > > > Thu, 12 Apr 2012 10:23:45 -0400 ?? jwcolby: >> I have pairs of flags and methods to set/get those flags, an Err and ErrMsg. Err is the date/time >> and ErrMsg is the message. >> >> It seems appropriate to call Err from ErrMsg, i.e. if I set an error message, have that property >> call the Err property to set the date / time as well. >> >> As it is I call two properties, one to set the date / time and the other to save the error message. >> >> Your thoughts? >> >> -- >> John W. Colby >> Colby Consulting >> >> Reality is what refuses to go away >> when you do not believe in it >> >> _______________________________________________ >> dba-VB mailing list >> dba-VB at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-vb >> http://www.databaseadvisors.com >> >> > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > From jwcolby at colbyconsulting.com Sun Apr 15 22:07:32 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sun, 15 Apr 2012 23:07:32 -0400 Subject: [dba-VB] The coming in-memory database tipping point. - SQL Server Team Blog - Site Home - TechNet Blogs Message-ID: <4F8B8CF4.8030804@colbyconsulting.com> -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it http://blogs.technet.com/b/dataplatforminsider/archive/2012/04/09/the-coming-in-memory-database-tipping-point.aspx From jwcolby at colbyconsulting.com Thu Apr 19 09:25:03 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Thu, 19 Apr 2012 10:25:03 -0400 Subject: [dba-VB] Expanding my mind Message-ID: <4F90203F.1030408@colbyconsulting.com> I am building an error tracking system for my Address validation system, the mongo system that validates the hundreds of millions of addresses every month. The system is so complex that I need to track all of the errors that can be generated for analysis and program control. So I am building an error class and error supervisor class. The system uses a clsManager which loads and sequences jobs, a clsSupervisor ( a job or table to be processed) and a clsProcess ( a chunk of a job / table being processed). The errors I am trying to track are errors specific to processing a supervisor or a process. So I have potentially two "levels" of errors, Supervisor and Process. In the end though they will all have a SupervisorID, and if the error occurred in a process they will have a ProcessID, after which they will have the same set of fields - a datetime, Program Error string, Exception Number (if any) and an Exception Message. I need to handle generating clsErr instances and filling out all of the properties, storing them to SQL Server, and loading any existing errors out of SQL Server as a supervisor or process loads. My question then is do I create a clsErrSuperv which handles the basic process but only has stuff for clsSupervisor generated errors, and then build a second clsErrProc which inherits clsErrSupervisor and adds on the additional fields for handling the process errors? Or just do a single class with the ProcessID field and load built in? I don't do any inheritance to this point and it sounds like this would be a good place to start. -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From jwcolby at colbyconsulting.com Sun Apr 22 21:28:35 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sun, 22 Apr 2012 22:28:35 -0400 Subject: [dba-VB] C# Inheritance question Message-ID: <4F94BE53.7040103@colbyconsulting.com> I have the following code which is in the base class: protected bool mLoadFromSQLSrvr(string SQL) { try { cnn = new SqlConnection(clsGlobals.myConnection); cnn.Open(); cmd = new SqlCommand(SQL, cnn); dr = cmd.ExecuteReader(); while ((dr.Read())) { mErrFactory(); } } catch (SqlException ex) { The problem is that mErrFactory is different in the base and derived class. Can this code be told to call the mErrFactory in the derived class? Or do I need to just carve out the while loop and have this method just get the data reader something like this: protected bool mSQLSrvrReader(string SQL) { try { cnn = new SqlConnection(clsGlobals.myConnection); cnn.Open(); cmd = new SqlCommand(SQL, cnn); dr = cmd.ExecuteReader(); return true; } } private bool mLoadFromSQLSrvr(string SQL) { if mSQLSrvrReader(strsql) { while ((dr.Read())) { mErrFactory(); } } } Then override mLoadFromSqlServer in the derived class? Since I know how to do the latter I am going there but I am wondering whether the base can be told to call an identically named method down in a derived class. It seems unlikely but what do I know? -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From fuller.artful at gmail.com Sun Apr 22 22:21:47 2012 From: fuller.artful at gmail.com (Arthur Fuller) Date: Sun, 22 Apr 2012 23:21:47 -0400 Subject: [dba-VB] C# Inheritance question In-Reply-To: <4F94BE53.7040103@colbyconsulting.com> References: <4F94BE53.7040103@colbyconsulting.com> Message-ID: I know much less than you about C# but what you want to do seems like a violation of the intended design. Anything the base class needs should live in it, not beneath it, no? A. On Sun, Apr 22, 2012 at 10:28 PM, jwcolby wrote: > I have the following code which is in the base class: > > protected bool mLoadFromSQLSrvr(string SQL) > { > try > { > cnn = new SqlConnection(clsGlobals.**myConnection); > cnn.Open(); > cmd = new SqlCommand(SQL, cnn); > dr = cmd.ExecuteReader(); > while ((dr.Read())) > { > mErrFactory(); > } > } > catch (SqlException ex) > { > > The problem is that mErrFactory is different in the base and derived > class. Can this code be told to call the mErrFactory in the derived class? > Or do I need to just carve out the while loop and have this method just > get the data reader something like this: > > protected bool mSQLSrvrReader(string SQL) > { > try > { > cnn = new SqlConnection(clsGlobals.**myConnection); > cnn.Open(); > cmd = new SqlCommand(SQL, cnn); > dr = cmd.ExecuteReader(); > return true; > } > } > > private bool mLoadFromSQLSrvr(string SQL) > { > > if mSQLSrvrReader(strsql) > { > while ((dr.Read())) > { > mErrFactory(); > } > > } > } > > Then override mLoadFromSqlServer in the derived class? > > Since I know how to do the latter I am going there but I am wondering > whether the base can be told to call an identically named method down in a > derived class. It seems unlikely but what do I know? > -- > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > ______________________________**_________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/**mailman/listinfo/dba-vb > http://www.databaseadvisors.**com > > -- Arthur Cell: 647.710.1314 Prediction is difficult, especially of the future. -- Niels Bohr From jwcolby at colbyconsulting.com Sun Apr 22 22:39:41 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Sun, 22 Apr 2012 23:39:41 -0400 Subject: [dba-VB] C# Inheritance question In-Reply-To: References: <4F94BE53.7040103@colbyconsulting.com> Message-ID: <4F94CEFD.9010001@colbyconsulting.com> Yep, it seems that way, except that the while loop really is "common" to the base and the derived, only the mErrFactory actually is different. Having to carve the While loop out adds another function to both base and derived. John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/22/2012 11:21 PM, Arthur Fuller wrote: > I know much less than you about C# but what you want to do seems like a > violation of the intended design. Anything the base class needs should live > in it, not beneath it, no? > > A. > > On Sun, Apr 22, 2012 at 10:28 PM, jwcolbywrote: > >> I have the following code which is in the base class: >> >> protected bool mLoadFromSQLSrvr(string SQL) >> { >> try >> { >> cnn = new SqlConnection(clsGlobals.**myConnection); >> cnn.Open(); >> cmd = new SqlCommand(SQL, cnn); >> dr = cmd.ExecuteReader(); >> while ((dr.Read())) >> { >> mErrFactory(); >> } >> } >> catch (SqlException ex) >> { >> >> The problem is that mErrFactory is different in the base and derived >> class. Can this code be told to call the mErrFactory in the derived class? >> Or do I need to just carve out the while loop and have this method just >> get the data reader something like this: >> >> protected bool mSQLSrvrReader(string SQL) >> { >> try >> { >> cnn = new SqlConnection(clsGlobals.**myConnection); >> cnn.Open(); >> cmd = new SqlCommand(SQL, cnn); >> dr = cmd.ExecuteReader(); >> return true; >> } >> } >> >> private bool mLoadFromSQLSrvr(string SQL) >> { >> >> if mSQLSrvrReader(strsql) >> { >> while ((dr.Read())) >> { >> mErrFactory(); >> } >> >> } >> } >> >> Then override mLoadFromSqlServer in the derived class? >> >> Since I know how to do the latter I am going there but I am wondering >> whether the base can be told to call an identically named method down in a >> derived class. It seems unlikely but what do I know? >> -- >> John W. Colby >> Colby Consulting >> >> Reality is what refuses to go away >> when you do not believe in it >> >> ______________________________**_________________ >> dba-VB mailing list >> dba-VB at databaseadvisors.com >> http://databaseadvisors.com/**mailman/listinfo/dba-vb >> http://www.databaseadvisors.**com >> >> > > From mcp2004 at mail.ru Mon Apr 23 04:18:56 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Mon, 23 Apr 2012 13:18:56 +0400 Subject: [dba-VB] =?utf-8?q?C=23_Inheritance_question?= In-Reply-To: <4F94CEFD.9010001@colbyconsulting.com> References: <4F94BE53.7040103@colbyconsulting.com> <4F94CEFD.9010001@colbyconsulting.com> Message-ID: Use virtual method in the base class and override it in a derived class. /SS-wp7 Sun, 22 Apr 2012 23:39:41 -0400 ?? jwcolby : > Yep, it seems that way, except that the while loop really is "common" to the > base and the derived, > only the mErrFactory actually is different. Having to carve the While loop > out adds another > function to both base and derived. > > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > On 4/22/2012 11:21 PM, Arthur Fuller wrote: > > I know much less than you about C# but what you want to do seems like a > > violation of the intended design. Anything the base class needs should live > > in it, not beneath it, no? > > > > A. > > > > On Sun, Apr 22, 2012 at 10:28 PM, jwcolbywrote: > > > >> I have the following code which is in the base class: > >> > >> protected bool mLoadFromSQLSrvr(string SQL) > >> { > >> try > >> { > >> cnn = new SqlConnection(clsGlobals.**myConnection); > >> cnn.Open(); > >> cmd = new SqlCommand(SQL, cnn); > >> dr = cmd.ExecuteReader(); > >> while ((dr.Read())) > >> { > >> mErrFactory(); > >> } > >> } > >> catch (SqlException ex) > >> { > >> > >> The problem is that mErrFactory is different in the base and derived > >> class. Can this code be told to call the mErrFactory in the derived class? > >> Or do I need to just carve out the while loop and have this method just > >> get the data reader something like this: > >> > >> protected bool mSQLSrvrReader(string SQL) > >> { > >> try > >> { > >> cnn = new SqlConnection(clsGlobals.**myConnection); > >> cnn.Open(); > >> cmd = new SqlCommand(SQL, cnn); > >> dr = cmd.ExecuteReader(); > >> return true; > >> } > >> } > >> > >> private bool mLoadFromSQLSrvr(string SQL) > >> { > >> > >> if mSQLSrvrReader(strsql) > >> { > >> while ((dr.Read())) > >> { > >> mErrFactory(); > >> } > >> > >> } > >> } > >> > >> Then override mLoadFromSqlServer in the derived class? > >> > >> Since I know how to do the latter I am going there but I am wondering > >> whether the base can be told to call an identically named method down in a > >> derived class. It seems unlikely but what do I know? > >> -- > >> John W. Colby > >> Colby Consulting > >> > >> Reality is what refuses to go away > >> when you do not believe in it > >> > >> ______________________________**_________________ > >> dba-VB mailing list > >> dba-VB at databaseadvisors.com > >> > http://databaseadvisors.com/**mailman/listinfo/dba-vb > >> http://www.databaseadvisors.**com > >> > >> > > > > > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com From jwcolby at colbyconsulting.com Wed Apr 25 08:17:42 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 25 Apr 2012 09:17:42 -0400 Subject: [dba-VB] Storing derived classes in a list Message-ID: <4F97F976.4090202@colbyconsulting.com> I have a dictionary which is typed to clsFlag private Dictionary lstClsSQLFlagGridUpdate = new Dictionary(); In my program I never actually instantiate clsFlag but rather derived classes which inherit clsFlag and use its functionality. So I am actually instantiating and storing clsFlagDte, clsFlagInt etc. In all other regards this seems to be working well. When I read a flag out I simply cast the flag to its real type and off I go. However there is one specific place in my code where the code does not know the type and thus leaves it as an object: public void mGridUpdate(clsGridValues gridValues) { lstClsSQLFlagGridUpdate[gridValues.pFieldName].pValue = gridValues.pValue; } IOW lstClsSQLFlagGridUpdate[gridValues.pFieldName] is a pointer to an object in the list, and that object is *not* clsFlag. However in this case the .pValue is calling pValue in the base class which is not what I intend. .PValue in the base class doesn't do anything. So basically I need to discover what subclass type is in the list and get an instance of that subclass (a pointer to the object in the list cast to the correct type), then update pValue of that pointed to object. I have no idea how to do that. I could do something klutzy like creating a "type variable" in each subclass and set that to the correct type in the constructor, and then in the method above use a switch to cast based on that "type variable" but that seems ugly. Is there some syntax to tell this thing to call the pValue method in the subclass instead of the base object? -- John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it From mcp2004 at mail.ru Wed Apr 25 11:54:58 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 25 Apr 2012 20:54:58 +0400 Subject: [dba-VB] =?utf-8?q?Storing_derived_classes_in_a_list?= In-Reply-To: <4F97F976.4090202@colbyconsulting.com> References: <4F97F976.4090202@colbyconsulting.com> Message-ID: Hi John -- Quick & Dirty: if (lstClsSQLFlagGridUpdate[gridValues.pFieldName] is clsFlagDte) { .... } else if (lstClsSQLFlagGridUpdate[gridValues.pFieldName] is clsFlagInt) { ... } As usual there should be many other (more elegant) (and OOP) ways to achieve the same results... Thank you. -- Shamil Wed, 25 Apr 2012 09:17:42 -0400 ?? jwcolby : > > I have a dictionary which is typed to clsFlag > > private Dictionary lstClsSQLFlagGridUpdate = new Dictionary(); > > In my program I never actually instantiate clsFlag but rather derived classes which inherit clsFlag > and use its functionality. So I am actually instantiating and storing clsFlagDte, clsFlagInt etc. > > In all other regards this seems to be working well. When I read a flag out I simply cast the flag > to its real type and off I go. However there is one specific place in my code where the code does > not know the type and thus leaves it as an object: > > public void mGridUpdate(clsGridValues gridValues) > { > lstClsSQLFlagGridUpdate[gridValues.pFieldName].pValue = gridValues.pValue; > } > > IOW lstClsSQLFlagGridUpdate[gridValues.pFieldName] is a pointer to an object in the list, and that > object is *not* clsFlag. > > However in this case the .pValue is calling pValue in the base class which is not what I intend. > .PValue in the base class doesn't do anything. > > So basically I need to discover what subclass type is in the list and get an instance of that > subclass (a pointer to the object in the list cast to the correct type), then update pValue of that > pointed to object. > > I have no idea how to do that. I could do something klutzy like creating a "type variable" in each > subclass and set that to the correct type in the constructor, and then in the method above use a > switch to cast based on that "type variable" but that seems ugly. > > Is there some syntax to tell this thing to call the pValue method in the subclass instead of the > base object? > > -- > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > > From jwcolby at colbyconsulting.com Wed Apr 25 12:00:40 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 25 Apr 2012 13:00:40 -0400 Subject: [dba-VB] Storing derived classes in a list In-Reply-To: <4F97F976.4090202@colbyconsulting.com> References: <4F97F976.4090202@colbyconsulting.com> Message-ID: <4F982DB8.5020708@colbyconsulting.com> Well I figured it out, Virtual and Override keywords. Sorry for the ring. This is my first foray into actually building my own base classes and inheriting from them. John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/25/2012 9:17 AM, jwcolby wrote: > > I have a dictionary which is typed to clsFlag > > private Dictionary lstClsSQLFlagGridUpdate = new Dictionary(); > > In my program I never actually instantiate clsFlag but rather derived classes which inherit clsFlag > and use its functionality. So I am actually instantiating and storing clsFlagDte, clsFlagInt etc. > > In all other regards this seems to be working well. When I read a flag out I simply cast the flag to > its real type and off I go. However there is one specific place in my code where the code does not > know the type and thus leaves it as an object: > > public void mGridUpdate(clsGridValues gridValues) > { > lstClsSQLFlagGridUpdate[gridValues.pFieldName].pValue = gridValues.pValue; > } > > IOW lstClsSQLFlagGridUpdate[gridValues.pFieldName] is a pointer to an object in the list, and that > object is *not* clsFlag. > > However in this case the .pValue is calling pValue in the base class which is not what I intend. > .PValue in the base class doesn't do anything. > > So basically I need to discover what subclass type is in the list and get an instance of that > subclass (a pointer to the object in the list cast to the correct type), then update pValue of that > pointed to object. > > I have no idea how to do that. I could do something klutzy like creating a "type variable" in each > subclass and set that to the correct type in the constructor, and then in the method above use a > switch to cast based on that "type variable" but that seems ugly. > > Is there some syntax to tell this thing to call the pValue method in the subclass instead of the > base object? > From jwcolby at colbyconsulting.com Wed Apr 25 12:11:26 2012 From: jwcolby at colbyconsulting.com (jwcolby) Date: Wed, 25 Apr 2012 13:11:26 -0400 Subject: [dba-VB] Storing derived classes in a list In-Reply-To: References: <4F97F976.4090202@colbyconsulting.com> Message-ID: <4F98303E.2060806@colbyconsulting.com> Thanks Shamil. I created the base property virtual and then used the override keyword on the derived classes and the framework automatically figured it out for me. John W. Colby Colby Consulting Reality is what refuses to go away when you do not believe in it On 4/25/2012 12:54 PM, Salakhetdinov Shamil wrote: > Hi John -- > > Quick& Dirty: > > if (lstClsSQLFlagGridUpdate[gridValues.pFieldName] is clsFlagDte) > { > .... > } > else if (lstClsSQLFlagGridUpdate[gridValues.pFieldName] is clsFlagInt) > { > ... > } > > As usual there should be many other (more elegant) (and OOP) ways to achieve the same results... > > Thank you. > > -- Shamil > > > Wed, 25 Apr 2012 09:17:42 -0400 ?? jwcolby: >> >> I have a dictionary which is typed to clsFlag >> >> private Dictionary lstClsSQLFlagGridUpdate = new Dictionary(); >> >> In my program I never actually instantiate clsFlag but rather derived classes which inherit clsFlag >> and use its functionality. So I am actually instantiating and storing clsFlagDte, clsFlagInt etc. >> >> In all other regards this seems to be working well. When I read a flag out I simply cast the flag >> to its real type and off I go. However there is one specific place in my code where the code does >> not know the type and thus leaves it as an object: >> >> public void mGridUpdate(clsGridValues gridValues) >> { >> lstClsSQLFlagGridUpdate[gridValues.pFieldName].pValue = gridValues.pValue; >> } >> >> IOW lstClsSQLFlagGridUpdate[gridValues.pFieldName] is a pointer to an object in the list, and that >> object is *not* clsFlag. >> >> However in this case the .pValue is calling pValue in the base class which is not what I intend. >> .PValue in the base class doesn't do anything. >> >> So basically I need to discover what subclass type is in the list and get an instance of that >> subclass (a pointer to the object in the list cast to the correct type), then update pValue of that >> pointed to object. >> >> I have no idea how to do that. I could do something klutzy like creating a "type variable" in each >> subclass and set that to the correct type in the constructor, and then in the method above use a >> switch to cast based on that "type variable" but that seems ugly. >> >> Is there some syntax to tell this thing to call the pValue method in the subclass instead of the >> base object? >> >> -- >> John W. Colby >> Colby Consulting >> >> Reality is what refuses to go away >> when you do not believe in it >> >> _______________________________________________ >> dba-VB mailing list >> dba-VB at databaseadvisors.com >> http://databaseadvisors.com/mailman/listinfo/dba-vb >> http://www.databaseadvisors.com >> >> > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > From mcp2004 at mail.ru Wed Apr 25 13:58:03 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Wed, 25 Apr 2012 22:58:03 +0400 Subject: [dba-VB] =?utf-8?q?Storing_derived_classes_in_a_list?= In-Reply-To: <4F98303E.2060806@colbyconsulting.com> References: <4F97F976.4090202@colbyconsulting.com> <4F98303E.2060806@colbyconsulting.com> Message-ID: Yes, John, You can also use an abstract base class as you don't need it to be instantiated and an abstract base method to make sure it will be redefined/overridden in a derived class... Thank you. -- Shamil Wed, 25 Apr 2012 13:11:26 -0400 ?? jwcolby : > Thanks Shamil. > > I created the base property virtual and then used the override keyword on the derived classes and > the framework automatically figured it out for me. > > John W. Colby > Colby Consulting > > Reality is what refuses to go away > when you do not believe in it > > On 4/25/2012 12:54 PM, Salakhetdinov Shamil wrote: > > Hi John -- > > > > Quick& Dirty: > > > > if (lstClsSQLFlagGridUpdate[gridValues.pFieldName] is clsFlagDte) > > { > > .... > > } > > else if (lstClsSQLFlagGridUpdate[gridValues.pFieldName] is clsFlagInt) > > { > > ... > > } > > > > As usual there should be many other (more elegant) (and OOP) ways to achieve the same results... > > > > Thank you. > > > > -- Shamil > > > > > > Wed, 25 Apr 2012 09:17:42 -0400 ?? jwcolby: > >> > >> I have a dictionary which is typed to clsFlag > >> > >> private Dictionary lstClsSQLFlagGridUpdate = new Dictionary(); > >> > >> In my program I never actually instantiate clsFlag but rather derived classes which inherit clsFlag > >> and use its functionality. So I am actually instantiating and storing clsFlagDte, clsFlagInt etc. > >> > >> In all other regards this seems to be working well. When I read a flag out I simply cast the flag > >> to its real type and off I go. However there is one specific place in my code where the code does > >> not know the type and thus leaves it as an object: > >> > >> public void mGridUpdate(clsGridValues gridValues) > >> { > >> lstClsSQLFlagGridUpdate[gridValues.pFieldName].pValue = gridValues.pValue; > >> } > >> > >> IOW lstClsSQLFlagGridUpdate[gridValues.pFieldName] is a pointer to an object in the list, and that > >> object is *not* clsFlag. > >> > >> However in this case the .pValue is calling pValue in the base class which is not what I intend. > >> .PValue in the base class doesn't do anything. > >> > >> So basically I need to discover what subclass type is in the list and get an instance of that > >> subclass (a pointer to the object in the list cast to the correct type), then update pValue of that > >> pointed to object. > >> > >> I have no idea how to do that. I could do something klutzy like creating a "type variable" in each > >> subclass and set that to the correct type in the constructor, and then in the method above use a > >> switch to cast based on that "type variable" but that seems ugly. > >> > >> Is there some syntax to tell this thing to call the pValue method in the subclass instead of the > >> base object? > >> > >> -- > >> John W. Colby > >> Colby Consulting > >> > >> Reality is what refuses to go away > >> when you do not believe in it > >> > >> _______________________________________________ > >> dba-VB mailing list > >> dba-VB at databaseadvisors.com > >> http://databaseadvisors.com/mailman/listinfo/dba-vb > >> http://www.databaseadvisors.com > >> > >> > > > > _______________________________________________ > > dba-VB mailing list > > dba-VB at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-vb > > http://www.databaseadvisors.com > > > > From mcp2004 at mail.ru Thu Apr 26 18:28:25 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Fri, 27 Apr 2012 03:28:25 +0400 Subject: [dba-VB] =?utf-8?q?A_couple_of_code_snippets=2E=2E=2E?= Message-ID: Hi All -- Just wanted to share a couple of test code samples I've got written here while working on real life development task. Please review, comment, remark, write your own versions. Test 1 ===== public void TestSort() { // simulate reading products' .csv file into text string StringBuilder text = new StringBuilder() .AppendLine("P1|12.34").AppendLine("P2|5.28").AppendLine("P3|21.74") .AppendLine("P4|67.12").AppendLine("P5|23.98"); // parse text string and add parsed items n into an array list ArrayList products = new ArrayList(); foreach (string textLine in text.ToString().Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { products.Add(new { Name = textLine.Substring(0, 2), Price = Decimal.Parse(textLine.Substring(3)) }); } // print sorted products list foreach (var product in (from p in products.Cast().OrderBy(x => x.Price) select p)) { System.Console.WriteLine(product); } } Test 2 (Test 1 variation using yield return) ================================ public void TestSort2() { // print sorted products list foreach (var product in (from p in GetProducts().OrderBy(x => x.Price) select p)) { System.Console.WriteLine(product); } } public IEnumerable GetProducts() { // simulate reading products' .csv file into text string StringBuilder text = new StringBuilder() .AppendLine("P1|12.34").AppendLine("P2|5.28").AppendLine("P3|21.74") .AppendLine("P4|67.12").AppendLine("P5|23.98"); // parse text string and add parsed item to IEnumerable using yield return foreach (string textLine in text.ToString().Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { yield return new { Name = textLine.Substring(0, 2), Price = Decimal.Parse(textLine.Substring(3)) }; } } Thank you. -- Shamil From hans.andersen at phulse.com Thu Apr 26 22:04:50 2012 From: hans.andersen at phulse.com (Hans-Christian Andersen) Date: Thu, 26 Apr 2012 20:04:50 -0700 Subject: [dba-VB] A couple of code snippets... In-Reply-To: References: Message-ID: <80C5F386-5D65-4680-86C4-1A4A155632E6@phulse.com> What sort of sorting algorithm is .orderby using internally? - Hans Sent from my iPhone On 2012-04-26, at 4:28 PM, Salakhetdinov Shamil wrote: > Hi All -- > > Just wanted to share a couple of test code samples I've got written here while working on real life development task. > Please review, comment, remark, write your own versions. > > Test 1 > ===== > > public void TestSort() > { > // simulate reading products' .csv file into text string > StringBuilder text = new StringBuilder() > .AppendLine("P1|12.34").AppendLine("P2|5.28").AppendLine("P3|21.74") > .AppendLine("P4|67.12").AppendLine("P5|23.98"); > > // parse text string and add parsed items n into an array list > ArrayList products = new ArrayList(); > foreach (string textLine in text.ToString().Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) > { > products.Add(new { Name = textLine.Substring(0, 2), Price = Decimal.Parse(textLine.Substring(3)) }); > } > > // print sorted products list > foreach (var product in (from p in products.Cast().OrderBy(x => x.Price) select p)) > { > System.Console.WriteLine(product); > } > } > > Test 2 (Test 1 variation using yield return) > ================================ > > public void TestSort2() > { > // print sorted products list > foreach (var product in (from p in GetProducts().OrderBy(x => x.Price) select p)) > { > System.Console.WriteLine(product); > } > } > > public IEnumerable GetProducts() > { > // simulate reading products' .csv file into text string > StringBuilder text = new StringBuilder() > .AppendLine("P1|12.34").AppendLine("P2|5.28").AppendLine("P3|21.74") > .AppendLine("P4|67.12").AppendLine("P5|23.98"); > > // parse text string and add parsed item to IEnumerable using yield return > foreach (string textLine in text.ToString().Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) > { > yield return new { Name = textLine.Substring(0, 2), Price = Decimal.Parse(textLine.Substring(3)) }; > } > } > > Thank you. > > -- Shamil > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com > From mcp2004 at mail.ru Fri Apr 27 03:24:25 2012 From: mcp2004 at mail.ru (=?UTF-8?B?U2FsYWtoZXRkaW5vdiBTaGFtaWw=?=) Date: Fri, 27 Apr 2012 12:24:25 +0400 Subject: [dba-VB] =?utf-8?q?A_couple_of_code_snippets=2E=2E=2E?= In-Reply-To: <80C5F386-5D65-4680-86C4-1A4A155632E6@phulse.com> References: <80C5F386-5D65-4680-86C4-1A4A155632E6@phulse.com> Message-ID: Hi Hans -- For your question: "What Sorting Algorithm Is Used By LINQ ?OrderBy??" please see http://stackoverflow.com/questions/2792074/what-sorting-algorithm-is-used-by-linq-orderby I have experimented a bit more with my coding (see P.S.) and for the following test calls: string p = "{type tab delimited text file fullpath here}"; TestSort5(System.Console.WriteLine, 1, p, 1); TestSort5(System.Console.WriteLine, 2, p, 10); TestSort5(System.Console.WriteLine, 3, p, 100); I have got: *** 1. 21297 products processed in 575.231 ms *** 2. 212970 products processed in 4540.040 ms *** 3. 2129700 products processed in 58487.657 ms Test is run on Win7 3+GB on a simple "mere mortals" dual core laptop (produced by DELL in year 2007). Sorting 2+ million input lines in 58 secs seems to be too slow(?) - is that input file reading code, which influences so badly on overall performance? Any comments, remarks and corrections are very welcome. Thank you. -- Shamil P.S. Test code sample: public void TestSort5(Action log, int testNum, string inputFileFullPath, int readCount) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); // print sorted products list int counter = 0; foreach (var product in (from p in GetProducts5(log, testNum, inputFileFullPath, readCount).OrderBy(x => x.Title) select p)) { if (++counter % 100000 == 0) { //System.Console.WriteLine("{0}. {1}", counter, product); } } stopWatch.Stop(); double ms = (stopWatch.ElapsedTicks * 1000.0) / Stopwatch.Frequency; log(string.Format("*** {0}. {1} products processed in {2:0.000} ms", testNum, counter, ms)); } public IEnumerable GetProducts5(Action log, int testNum, string inputFileFullPath, int readCount) { const int SKU_FIELD_INDEX = 3; const int TITLE_FIELD_INDEX = 4; // parse text string and add parsed item to IEnumerable using yield return foreach (string textLine in InputLines(inputFileFullPath, readCount)) { string[] fields = textLine.Split(new char[] { '\t' }); yield return new { SKU = fields[SKU_FIELD_INDEX], Title = fields[TITLE_FIELD_INDEX] }; } } public IEnumerable InputLines(string inputFileFullPath, int readCount) { string[] lines = new string[] { "" }; for (int i = 1; i <= readCount; i++) foreach (string textLine in System.IO.File.ReadAllLines(inputFileFullPath, Encoding.UTF8)) yield return textLine; } Thu, 26 Apr 2012 20:04:50 -0700 ?? Hans-Christian Andersen : > What sort of sorting algorithm is .orderby using internally? > > - Hans > > Sent from my iPhone > > On 2012-04-26, at 4:28 PM, Salakhetdinov Shamil wrote: > > > Hi All -- > > > > Just wanted to share a couple of test code samples I've got written here while working on real life development task. > > Please review, comment, remark, write your own versions. > > > > Test 1 > > ===== > > > > public void TestSort() > > { > > // simulate reading products' .csv file into text string > > StringBuilder text = new StringBuilder() > > .AppendLine("P1|12.34").AppendLine("P2|5.28").AppendLine("P3|21.74") > > .AppendLine("P4|67.12").AppendLine("P5|23.98"); > > > > // parse text string and add parsed items n into an array list > > ArrayList products = new ArrayList(); > > foreach (string textLine in text.ToString().Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) > > { > > products.Add(new { Name = textLine.Substring(0, 2), Price = Decimal.Parse(textLine.Substring(3)) }); > > } > > > > // print sorted products list > > foreach (var product in (from p in products.Cast().OrderBy(x => x.Price) select p)) > > { > > System.Console.WriteLine(product); > > } > > } > > > > Test 2 (Test 1 variation using yield return) > > ================================ > > > > public void TestSort2() > > { > > // print sorted products list > > foreach (var product in (from p in GetProducts().OrderBy(x => x.Price) select p)) > > { > > System.Console.WriteLine(product); > > } > > } > > > > public IEnumerable GetProducts() > > { > > // simulate reading products' .csv file into text string > > StringBuilder text = new StringBuilder() > > .AppendLine("P1|12.34").AppendLine("P2|5.28").AppendLine("P3|21.74") > > .AppendLine("P4|67.12").AppendLine("P5|23.98"); > > > > // parse text string and add parsed item to IEnumerable using yield return > > foreach (string textLine in text.ToString().Split(new string[] { System.Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) > > { > > yield return new { Name = textLine.Substring(0, 2), Price = Decimal.Parse(textLine.Substring(3)) }; > > } > > } > > > > Thank you. > > > > -- Shamil > > > > _______________________________________________ > > dba-VB mailing list > > dba-VB at databaseadvisors.com > > http://databaseadvisors.com/mailman/listinfo/dba-vb > > http://www.databaseadvisors.com > > > From accessd at shaw.ca Sun Apr 29 19:50:46 2012 From: accessd at shaw.ca (Jim Lawrence) Date: Sun, 29 Apr 2012 17:50:46 -0700 Subject: [dba-VB] Visual Studio and Active Directory In-Reply-To: References: <80C5F386-5D65-4680-86C4-1A4A155632E6@phulse.com> Message-ID: <627FA943B1534770B0F5F810FCD9C3B2@creativesystemdesigns.com> Hi All: Does any one know how Visual Studio could connect to Active Directory? TIA Jim From hadyn at dataconcepts.co.nz Sun Apr 29 19:57:17 2012 From: hadyn at dataconcepts.co.nz (Hadyn) Date: Mon, 30 Apr 2012 12:57:17 +1200 Subject: [dba-VB] Visual Studio and Active Directory In-Reply-To: <627FA943B1534770B0F5F810FCD9C3B2@creativesystemdesigns.com> References: <80C5F386-5D65-4680-86C4-1A4A155632E6@phulse.com> <627FA943B1534770B0F5F810FCD9C3B2@creativesystemdesigns.com> Message-ID: Hi Jim Best resource I have found (watch for wrap): http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C# Cheers Hadyn -----Original Message----- > From: "Jim Lawrence" > To: "Discussion concerning Visual Basic and related programming issues." > Date: 30/04/2012 12:51 > Subject: [dba-VB] Visual Studio and Active Directory > > Hi All: > > Does any one know how Visual Studio could connect to Active Directory? > > TIA > Jim > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com From accessd at shaw.ca Mon Apr 30 00:58:17 2012 From: accessd at shaw.ca (Jim Lawrence) Date: Sun, 29 Apr 2012 22:58:17 -0700 Subject: [dba-VB] Visual Studio and Active Directory In-Reply-To: References: <80C5F386-5D65-4680-86C4-1A4A155632E6@phulse.com><627FA943B1534770B0F5F810FCD9C3B2@creativesystemdesigns.com> Message-ID: <54D16AB686614960B0474B1E20A4682E@creativesystemdesigns.com> Thank you very much Hadyn. It looks excellent but it will take a few days before serious testing can take place. Jim -----Original Message----- From: dba-vb-bounces at databaseadvisors.com [mailto:dba-vb-bounces at databaseadvisors.com] On Behalf Of Hadyn Sent: Sunday, April 29, 2012 5:57 PM To: Discussion concerning Visual Basic and related programming issues. Subject: Re: [dba-VB] Visual Studio and Active Directory Hi Jim Best resource I have found (watch for wrap): http://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active- Directory-via-C# Cheers Hadyn -----Original Message----- > From: "Jim Lawrence" > To: "Discussion concerning Visual Basic and related programming issues." > Date: 30/04/2012 12:51 > Subject: [dba-VB] Visual Studio and Active Directory > > Hi All: > > Does any one know how Visual Studio could connect to Active Directory? > > TIA > Jim > > _______________________________________________ > dba-VB mailing list > dba-VB at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-vb > http://www.databaseadvisors.com _______________________________________________ dba-VB mailing list dba-VB at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-vb http://www.databaseadvisors.com