I need to call a function at a specific time during a day. There are other examples in the internet using, Timer etc. But I am wondering, why not simply have a thread which calls a method having a while loop.               while (true)             {                 if (DateTime.Now.TimeOfDay == new TimeSpan(0, 0, 0))                 {                     ManualTaskProcession();                 }             }   This will be run on a separate thread - wondering why this approach is not mentioned anywhere, or is it correct?  P.S This is inside a Windows Service.
Is there any clever method out there to make my executeEveryDayMethod() execute once a day, without having to involve the Windows TaskScheduler?
I would like to use Class.newInstance() but the class I am instantiating does not have a nullary constructor. Therefore I need to be able to pass in constructor arguments. Is there a way to do this? How to subtract days from a plain Date? Why are so many different types of objects white, yet appear gray when they are wet? There are many things with different textures that appear white – salt, beer foam, paper, shaving cream, snow, talcum powder, white paint, etc. The most common answer is all of the frequencies must be reflected in order for us to perceive white, which I already know. There must be more underlining details why such a huge variety of things are white. Furthermore, if you wet paper, snow or talcum powder, they appear off-white or gray. Why is this? Prove that if $n$ is a composite, then $2^n-1$ is composite. Not sure if I'm doing this correctly but this is what I've done:  Assume that $n$ is composite and suppose $2^n-1$ is a prime for $n \gt 2$. Then, $2^n-1 = 2k$ for some $k \in \Bbb Z $, $\forall n$.  But this would be a contradiction since $n \gt 2$.  I'm not sure if this a correct proof.  EDIT: I realized that it's to prove $2^n - 1$ NOT $2^{n-1}$ so my attempt above is completely wrong. How do I get attention for one of my own questions without a good answer? I asked a question almost as soon as I got my account. I got a few decent answers, but none of them helped solve my problem. The question has long since become buried by newer questions, and there's still no accepted answer. Unfortunately, because there are quite a few answers with votes, to a casual observer it probably looks like the question was answered and I just neglected to mark an answer as accepted, and the system does not consider it "unanswered".  Or, I asked a question that was a bit more difficult to answer. After waiting for some time, I received no answers, little or no comments, and only a few views. The question does show up in the "unanswered" list, but no one has answered my question.  In either case, what's the protocol for me to try to get this question answered?  I see several options:   Post the question a second time, possibly linking to the original, to get attention for the original question. This is encouraged on sites like Reddit.  However, it's probably not appropriate here, since we're encouraged to check for duplicates and not submit a question that's already been asked by someone else, so this probably falls under that heading. Wait for some kind of wiki-like talk page to be implemented, then post a plea on the talk page for input and hope that activity on the talk page bumps up the question. Edit the question, but do nothing further on the Stack Exchange site. If I edit my post to say that I haven't accepted any of the current answers but am looking for more, then the question might get answered eventually by people browsing through old questions to find something they can answer. Post the question on other sites, but link to my original question on Stack Exchange. People will either answer here, or they'll answer on the other site and I can post the accepted answer here myself.  This might be considered spamming, so it might be better to do this without the link.      For more information, see the "" page in the . I need to knock out a quick animation in C#/Windows Forms for a Halloween display.  Just some 2D shapes moving about on a solid background.  Since this is just a quick one-off project I really don't want to install and learn an entire new set of tools for this.  (DirectX dev kits, Silverlight, Flash, etc..)  I also have to install this on multiple computers so anything beyond the basic .Net framework (2.0) would be a pain in the arse.  For tools I've got VS2k8, 25 years of development experience, a wheelbarrow, holocaust cloak, and about 2 days to knock this out.  I haven't done animation since using assembler on my Atari 130XE (hooray for page flipping and player/missile graphics!)  Advice?  Here's some of the things I'd like to know:   I can draw on any empty widget (like a panel) by fiddling with it's OnPaint handler, right?  That's how I'd draw a custom widget.  Is there a better technique than this? Is there a page-flipping technique for this kind of thing in Windows Forms?  I'm not looking for a high frame rate, just as little flicker/drawing as necessary.   Thanks.  Post Mortem Edit ... "a couple of coding days later"  Well, the project is done.  The links below came in handy although a couple of them were 404.  (I wish SO would allow more than one reply to be marked "correct").  The biggest problem I had to overcome was flickering, and a persistent bug when I tried to draw on the form directly.   Using the OnPaint event for the Form: bad idea.  I never got that to work; lots of mysterious errors (stack overflows, or ArgumentNullExceptions).  I wound up using a panel sized to fill the form and that worked fine. Using the OnPaint method is slow anyway.  Somewhere online I read that building the PaintEventArgs was slow, and they weren't kidding.  Lots of flickering went away when I abandoned this.  Skip the OnPaint/Invalidate() and just paint it yourself.  Setting all of the "double buffering" options on the form still left some flicker that had to be fixed.  (And I found conflicting docs that said "set them on the control" and "set them on the form".  Well controls don't have a .SetStyle() method.)  I haven't tested without them, so they might be doing something (this is the form):      this.SetStyle(ControlStyles.UserPaint, true);     this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);    So the workhorse of the code wound up looking like (pf is the panel control):      void PaintPlayField()     {         Bitmap bufl = new Bitmap(pf.Width, pf.Height);         using (Graphics g = Graphics.FromImage(bufl))         {             g.FillRectangle(Brushes.Black, new Rectangle(0, 0, pf.Width, pf.Height));             DrawItems(g);             DrawMoreItems(g);             pf.CreateGraphics().DrawImageUnscaled(bufl, 0, 0);         }     }   And I just called PaintPlayField from the inside of my Timer loop.  No flicker at all. Is there a BNF grammar of the TeX language? I'm looking for a BNF grammar of the TeX language, does it exist?  EDIT  For those of us who are not computer scientists, a BNF grammar is one kind of formal description of a CFG: .  For those who don't know their Chomsky, a CFG is a , which means (very roughly) that substitutions can be made independently of their use context. I notice that modern C and C++ code seems to use size_t instead of int/unsigned int pretty much everywhere - from parameters for C string functions to the STL.  I am curious as to the reason for this and the benefits it brings. Distribution of a ratio of uniforms: What is wrong? Suppose that  $X$ and $Y$ are two i.i.d. uniform random variables on the interval $[0,1]$  Let $Z=X/Y$, I am finding the cdf of $Z$, i.e. $ \Pr(Z\leq z) $.  Now, I came up with two ways of doing this. One produces a correct answer consistent with the pdf here: , the other does not. Why is the second method wrong?  First Method  $\newcommand{\rd}{\mathrm{d}} \Pr(Z\leq z) = \Pr(X/Y\leq z) = \Pr(X\leq zY) = \int^{1}_{0}\int^{\min(1,zy)}_{0} \rd x \rd y = \int^{1}_{0}\min(1,zy)\ \rd y$ $  = \left\{      \begin{array}{lr}        \int^{1/z}_{0}zy\ \rd y + \int^{1}_{1/z} \rd y&amp; : z &gt; 1\\        \int^{1}_{0}zy\ \rd y &amp; : z \leq 1      \end{array}    \right. $ $  = \left\{      \begin{array}{lr}        1 - \frac{1}{2z} &amp; : z &gt; 1\\        \frac{z}{2} &amp; : z \leq 1      \end{array}    \right. $  This appears correct.  Second Method  $\Pr(X/Y\leq z) = \Pr(X \leq zY\ |\ zY \geq 1)\Pr(zY \geq 1) + \Pr(X \leq zY\ |\ zY &lt; 1)\Pr(zY &lt; 1) $ by total probability  $ = \Pr(X \leq zY\ |\ zY \geq 1)\Pr(Y \geq 1/z) + \Pr(X \leq zY\ |\ zY &lt; 1)\Pr(Y &lt; 1/z)$  Taking $z&gt;1$ yields $ (1)(1-\frac{1}{z}) + (\int^{1/z}_{0}\int^{zy}_{0} \rd x \rd y)(\frac{1}{z}) = 1-\frac{1}{z} + (\int^{1/z}_{0}zy\ \rd y)(\frac{1}{z}) = 1-\frac{1}{z} + \frac{1}{2z^{2}}$  This is already different. Why is this wrong?  Thanks! How do I integrate the Poisson equation to determine the electric potential along a particular direction (e.g., $z$)? This question is a sequel of sorts to my  about .  In the paper, the authors performed molecular dynamics (MD) simulations of parallel-plate supercapacitors, in which liquid resides between the parallel-plate electrodes.  The system has a "slab" geometry, so the authors are only interested in variations of the liquid structure along the $z$ direction.  In my previous question, I asked about how particle number density is computed.  In this question, I would like to ask about how the electric potential is computed, given the charge density distribution.  Recall that in CGS (Gaussian) units, the Poisson equation is   $$\nabla^2 \Phi = -4\pi \rho$$  where $\Phi$ is the electric potential and $\rho$ is the charge density.  So the charge density $\rho$ is proportional to the Laplacian of the potential.  Now suppose I want to find the potential $\Phi(z)$ along $z$, by integrating the Poisson equation.  How can I do this?  In the paper, on page 254, the authors write down the average charge density $\bar{\rho}_{\alpha}(z)$ at $z$:  $$\bar{\rho}_{\alpha}(z) = A_0^{-1} \int_{-x_0}^{x_0} \int_{-y_0}^{y_0} dx^{\prime} \; dy^{\prime} \; \rho_{\alpha}(x^{\prime}, y^{\prime}, z)$$  where $\rho_{\alpha}(x, y, z)$ is the local charge density arising from the atomic charge distribution of ionic species $\alpha$, $\bar{\rho}_{\alpha}(z)$ is the average charge density at $z$ obtained by averaging $\rho_{\alpha}(x, y, z)$ over $x$ and $y$, and $\sum_{\alpha}$ denotes sum over ionic species.  The authors then integrate the Poisson equation to obtain $\Phi(z)$:  $$\Phi(z) = -4\pi \sum_{\alpha} \int_{-z_0}^z (z - z^{\prime}) \bar{\rho}_{\alpha}(z^{\prime}) \; dz^{\prime} \; \; \; \; \textbf{(eq. 2)}$$  My question is, how do I "integrate the Poisson equation" to obtain equation (2)?  How do I go from  $\nabla^2 \Phi = -4\pi \rho$ to equation (2)?  In paricular, where does the $(z - z^{\prime})$ factor come from?   Thanks for your time. Interpreting coefficient in a linear regression model with categorical variables I will give my examples with R calls. First a simple example of a linear regression with a dependent variable 'lifespan', and two continuous explanatory variables.  data.frame(height=runif(4000,160,200))-&gt;human.life human.life$weight=runif(4000,50,120) human.life$lifespan=sample(45:90,4000,replace=TRUE) summary(lm(lifespan~1+height+weight,data=human.life))  Call: lm(formula = lifespan ~ 1 + height + weight, data = human.life)  Residuals: Min       1Q   Median       3Q      Max  -23.0257 -11.9124  -0.0565  11.3755  23.8591   Coefficients:              Estimate Std. Error t value Pr(&gt;|t|)     (Intercept) 63.635709   3.486426  18.252   &lt;2e-16 *** height       0.007485   0.018665   0.401   0.6884     weight       0.024544   0.010428   2.354   0.0186 *   --- Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1   Residual standard error: 13.41 on 3997 degrees of freedom Multiple R-squared: 0.001425,   Adjusted R-squared: 0.0009257  F-statistic: 2.853 on 2 and 3997 DF,  p-value: 0.05781   In order to find the estimate of 'lifespan' when the value of 'weight' is 1, I add (Intercept)+height=63.64319  Now what if I have a similar data frame, but one where one of the explanatory variables is categorical?  data.frame(animal=rep(c("dog","fox","pig","wolf"),1000))-&gt;animal.life animal.life$weight=runif(4000,8,50) animal.life$lifespan=sample(1:10,replace=TRUE) summary(lm(lifespan~1+animal+weight,data=animal.life))  Call: lm(formula = lifespan ~ 1 + animal + weight, data = animal.life)  Residuals: Min      1Q  Median      3Q     Max  -4.7677 -2.7796 -0.1025  3.1972  4.3691   Coefficients:             Estimate Std. Error t value Pr(&gt;|t|)     (Intercept) 5.565556   0.145851  38.159  &lt; 2e-16 *** animalfox   0.806634   0.131198   6.148  8.6e-10 *** animalpig   0.010635   0.131259   0.081   0.9354     animalwolf  0.806650   0.131198   6.148  8.6e-10 *** weight      0.007946   0.003815   2.083   0.0373 *   --- Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1   Residual standard error: 2.933 on 3995 degrees of freedom Multiple R-squared: 0.01933,    Adjusted R-squared: 0.01835  F-statistic: 19.69 on 4 and 3995 DF,  p-value: 4.625e-16   In this case, to find the estimate of 'lifespan' when the value of 'weight' is 1, should I add each of the coefficients for 'animal' to the intercept: (Intercept)+animalfox+animalpig+animalwolf? Or what is the proper way to do this?  Thanks Sverre Home Electric Panel Questions I’m having a pool put in and the pool guys said they need a 20 amp breaker for the pool equipment. My outside panel says 100 amps (see picture). But my panel inside adds up well over 100 amps. Is this normal?  The breakers never trip even with the dryer, AC, and other appliances running. Do you ever center AND standardize variables in multiple regression? It seems as if standardization would automatically center variables...is this true? Hello,   I create an app using the Promoted Links in Sharepoint 2013. I chose to do this because the feature has the awesome hover effect and is easy to customize the image.  The issue is that I have been trying to figure out how to change the tile sizes. They are awesome the way they are, however I just need them smaller. I still want the hover effect as well and for the text to match the same ratio as the tile. I have tried web zones, I have done each ID but with no luck. I have attached a sample image of the tiles I'm referring to. Please help. How to change specific values in a List putting a tikzpicture inside a \caption{} I'm attempting to put a small tikzpicture inside a \caption{} belonging to a figure environment. The reason for doing this is fairly simple - to create an in-caption legend for a PGFplot, with consistency between the TikZ styles in the figure and in the caption. Previously I would have done this using dashes and the xcolor package, however, this is an awful hack. In this MWE:  \documentclass{article} \usepackage{tikz} \begin{document} \begin{figure} \caption{\raisebox{0.5ex}{ \begin{tikzpicture}\draw[dashed,color=red,thick] (0,0) -- (0.5,0);\end{tikzpicture}} Gas--Phase}  \end{figure} \end{document}   The expected output:    is generated, but I get ! Argument of \@caption has an extra }. and ! Paragraph ended before \@caption was complete. Within the larger context of the document that I'm writing, which includes chapters in external .tex files, compilation fails catastrophically (dozens of errors) with no output, so I can't just ignore the warnings in this instance. Any ideas? How do we delete subscribers (emails) from Auto suppression list using SSJS. Also, Auto suppression list maintain at SF end or application level. I'm planning a trip to recover a motorcycle from a distant city. The ideal trip would be flying to that location and coming back riding the bike, but that would require me to transport my riding gear with me in the plane: Leathers, boots, gloves, back protector and crash helmet.  All this is bulky and expensive stuff, and a crash helmet may be damaged if dropped or hit hard.   I don't expect any airline to allow me a crash helmet as hand luggage; and wearing it all the time is out of the question :-)   To complicate things, I would be coming back riding the bike, so any hard suitcase would have to be left behind.   How do people normally transport that kind of stuff? Uniform convergence with two sequences of functions For, $n\ge 1$ let, $g_n(x)=\sin^2(x+1/n)$ , $x\in [0,\infty)$ and $f_n(x)=\int_0^xg_n(t)\,dt.$  Then, which is(/are) correct ?  (A) $\{f_n(x)\} $ converges pointwise to a function $f$ on $[0,\infty)$ but does not converge uniformly on $[0,\infty)$.  (B) $\{f_n(x)\} $ does not converge pointwise to any function on $[0,\infty)$.  (C) $\{f_n(x)\} $ converges uniformly on $[0,1]$.  (D)  $\{f_n(x)\} $ converges uniformly on $[0,\infty)$.  I found that, $$f_n(x)=\frac{1}{2}\left[x-\frac{1}{2}\sin(x+1/n)+\frac{1}{2}\sin(1/n)\right].$$  So, $f(x)=\lim_{n}f_n(x)=\frac{x}{2}-\frac{1}{4}\sin x$.  Now, $|f_n(x)-f(x)|\le 3/4$. So, by M-test, $f_n(x)$ is not uniformly convergent, but point-wise convergent. So option (A) is correct..Am I right?? Yes, I'm really sure I want to delete that post