I'm working on a C# application.   I have an object used like a dialog box :  public partial class MyDialog : Form   The main windows is :  public class MyForm : Form   I can use it by :  public class ProgramApp {     public static MyForm MainForm { get { return _mainForm;  } } }   In one function I can use both with :  MyDialog dlg = new MyDialog(); dlg.ShowDialog(ProgramApp.MainForm);   First call works good, but at the second one I have a System.InvalidOperationException with HResult = 0x80131509 and message :     Cross-thread operation not valid: Control 'MainForm' accessed from a   thread other than the thread it was created on.   (translated from french, original message :)     "Opération inter-threads non valide : le contrôle 'MainForm' a   fait l'objet d'un accès à partir d'un thread autre que celui sur   lequel il a été créé."   What can I do to fix that ?  Edit :  I added this piece of code :  MyDialog dlg = new MyDialog(); bool needInvokeDlg = dlg.InvokeRequired; bool needInvokeForm = ProgramApp.MainForm.InvokeRequired; dlg.ShowDialog(ProgramApp.MainForm);   First attempt both are false. On second, needInvokeForm is true. How can I do an Invoke to set ProgramApp.MainForm as a parameter ?
I have a scenario. (Windows Forms, C#, .NET)   There is a main form which hosts some user control. The user control does some heavy data operation, such that if I directly call the UserControl_Load method the UI become nonresponsive for the duration for load method execution. To overcome this I load data on different thread (trying to change existing code as little as I can)   I used a background worker thread which will be loading the data and when done will notify the application that it has done its work.   Now came a real problem. All the UI (main form and its child usercontrols) was created on the primary main thread. In the LOAD method of the usercontrol I'm fetching data based on the values of some control (like textbox) on userControl.    The pseudocode would look like this:  CODE 1  UserContrl1_LoadDataMethod() {     if (textbox1.text == "MyName") // This gives exception     {         //Load data corresponding to "MyName".         //Populate a globale variable List&lt;string&gt; which will be binded to grid at some later stage.     } }   The Exception it gave was     Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.   To know more about this I did some googling and a suggestion came up like using the following code  CODE 2  UserContrl1_LoadDataMethod() {     if (InvokeRequired) // Line #1     {         this.Invoke(new MethodInvoker(UserContrl1_LoadDataMethod));         return;     }      if (textbox1.text == "MyName") // Now it wont give an exception     {     //Load data correspondin to "MyName"         //Populate a globale variable List&lt;string&gt; which will be binded to grid at some later stage     } }   BUT BUT BUT... it seems I'm back to square one. The Application again  become nonresponsive. It seems to be due to the execution of line #1 if condition. The loading task is again done by the parent thread and not the third that I spawned.  I don't know whether I perceived this right or wrong. I'm new to threading.  How do I resolve this and also what is the effect of execution of Line#1 if block?  The situation is this: I want to load data into a global variable based on the value of a control. I don't want to change the value of a control from the child thread. I'm not going to do it ever from a child thread.   So only accessing the value so that the corresponding data can be fetched from the database.
How can std::make_heap be implemented while making at most 3N comparisons? Why are packages in the official Ubuntu repositories older than the latest (upstream) versions from Debian Sid, PPAs, the authors, etc.? Finite Sum of Power? I read this story a long time ago and cannot remember either the title or the author. It was written in the 60s or 70s. The setting is sometime in the 21 century.  Here is a summary of the plot.  One of the great classical composers (maybe it was Schubert, I'm not sure) is revived with some future technology. All the guys in the lab are very happy about it, the world cheers the achievement. The composer is also quite excited to be alive. Naturally, he is asked to perform a concert. He asks for ink and music paper. Nobody knows what that is: in those days everybody writes music directly in "frequency spectrum" and similar stuff.  The composer, excited to create music again, tries to come up with something but he doesn't like anything he writes. The music is well written, but lacks something essential, it doesn't sound like his real music. Finally, the composer realizes that the lab guys recreated his mind from reviews by music critics, and his music just sounds like that. He performs the concert. The audience enjoys it, applauds and bravos. Not only to composer, but also to the lab guys.   At the end, if I remember it right, the composer gloats over the  primitive taste of the audience. The audience who writes music in frequency spectrum and applauds to lab guys at the music concert did not see the failure in the concert and ate it as it is.  Does someone recognize the story?  PS all the recent talk of advent of AI machines with Machine Learning algorithms reminded me of this story. Search [tag1] OR [tag2] Is there a way to search questions that are tagged with either tag1 or tag2?  Actually, I would like the general filter,      ([tag1] AND [tag2], ...) OR ([tag3]   AND [tag4], ...) OR ...   And even     [tag1] AND ([tag2] OR [tag3])   I need that because I'm looking for interesting questions and I have to search for each tag separately. Error with \newcommand using \multicolumn in table I want to define a new command \tableheadline that (1) formats the headline text in some way and (2) takes an optional argument for spanning multiple columns while centering the headline.  I tried the following implementation:  \documentclass{minimal}  \newcommand{\tableheadline}[2][1]{\multicolumn{#1}{c}{\textit{#2}}} % \newcommand{\tableheadline}[2][1]{\multicolumn{1}{c}{\textit{#2}}}  \begin{document}   \begin{tabular}[\textwidth]{cc}      \tableheadline[2]{C}     \tableheadline{A} &amp; \tableheadline{B} \\     0 &amp; 1 \\     2 &amp; 3 \\   \end{tabular} \end{document}   This, however, gives me an error:  ! Misplaced \omit. \multispan -&gt;\omit                    \@multispan l.8 \tableheadline[2]{C}   I also get the error when I do not even use the optional argument (see commented line in the MWE). Any ideas what I am doing wrong? $G$ is non abelian simple group of order $<100$ then $G\cong A_5$ can't read from SQlite database What is currently the most reliable VPN for China? I will soon be spending a few months travelling across China and want to get a VPN service to get around the Golden Firewall.   When I was in China in 2014/15 the general consensus was that Astrill offered the most reliable service, but I heard that they have been targeted quite strongly by the government over the last year.   Therefore, I am wondering what is the best VPN for China these days? Is Astrill still as good as it used to be?   Any recent experiences would be very helpful! Ideal in a ring of continuous functions Does anyone know what the Inverse Cumulative Distribution Function of Normal Distribution is? Does it have a closed form expression? I did not find any good answer using Google. How to determine the architecture of an installation or Live CD/DVD? How can I determine which architecture (x86 or x64) my Ubuntu installation medium is for?  I don't have it installed, I just need to know which files on the installation media I can use to determine the architecture. Should I retag a question with a tag that is based on the answer and not the question? Here's a scenario:  Someone asked about "How to build a SQL query to get count and blah blah blah..."  His only tag is . I added the  and  tags to it.  Someone else answered with a nice SQL statement that has a "group by" statement which seems "logically inevitable".  I proceed to add a tag . I did that on the basis that someone who searches for  will be able to find this post useful, just as I did. My concern is, it wasn't described at all in the question, nor was it implied, unlike  and .  What is the community opinion?  The scenario above is a real one . And the one who answered it nicely is Jon Skeet. How to get battery status? How do I get the battery status on an iPhone? Hello,  I'm getting this error every time when I boot my computer. My Ubuntu installation is fresh and I was got a few error on last step while install Ubuntu (because i have problem with my CDROM driver). Anyway, installation is continued .   For example when i tried to open ADDITIONAL DRIVER and LANGUAGE SUPPORT (on System Settings) nothing happened, it's not opening.  When i try this in terminal gnome-language-selector i'm getting this error  Traceback (most recent call last):   File "/usr/bin/gnome-language-selector", line 8, in &lt;module&gt;     from LanguageSelector.gtk.GtkLanguageSelector import GtkLanguageSelector   File "/usr/lib/python2.7/dist-packages/LanguageSelector/gtk/GtkLanguageSelector.py", line 34, in &lt;module&gt;     from aptdaemon.gtk3widgets import AptProgressDialog   File "/usr/lib/python2.7/dist-packages/aptdaemon/gtk3widgets.py", line 61, in &lt;module&gt;     class AptStatusIcon(Gtk.Image):   File "/usr/lib/python2.7/dist-packages/aptdaemon/gtk3widgets.py", line 66, in AptStatusIcon     def __init__(self, transaction=None, size=Gtk.IconSize.DIALOG): AttributeError: type object 'GtkIconSize' has no attribute 'DIALOG'   Also getting this error for jockey-gtk  Traceback (most recent call last):   File "/usr/bin/jockey-gtk", line 418, in &lt;module&gt;     sys.exit(u.run())   File "/usr/lib/python2.7/dist-packages/jockey/ui.py", line 461, in run     self.ui_show_main()   File "/usr/bin/jockey-gtk", line 81, in ui_show_main     col_icon.set_sizing(Gtk.TreeViewColumnSizing.AUTOSIZE) AttributeError: type object 'GtkTreeViewColumnSizing' has no attribute 'AUTOSIZE'   I'm worrying about are there any lack . I don't know what's wrong with my installation.  Are there any way, check my installation (packages, files etc..) . Why are hard drives never as large as advertised? From all the hard drives I have bought, they never seem to be as large as the advertised size; from 320 GB down to 290 GB, from 500 GB down to 450 GB, etc. Is there a technical reason for this? In terminal, how can I write 'sagi' instead of 'sudo apt-get install' Position of \caption gets counter incremented twice Moving from SQL 2005 [SQL_Latin1_General_CP1_CI_AS] to 2008 - will I lose any features by using 'backwards compatibility' Changing pemalink structure to /%post_id%/%postname%/ I'm currently using permalink structure: /%year%/%monthnum%/%day%/%postname%/  I want to change that to: /%post_id%/%postname%/  I expect it to be:   faster (database is sorted by post_id?) shorter URLs (and clearly visible short verstions, just leaving the %postname%/ out) more SEO friendly - since my content is "evergreen" so publishing date is irrelevant (and written at each post, along with last update date) - so this would give shorter URLs, with no downsides compared to using year/month/day structure.   THE QUESTION: Does WordPress handle all the 301 redirects automatically? I can fix internal links to the new structure (though I'd expect that to be automatic as well), but worry about outsite links, pointing to my posts/articles.  If not, what's the best way to implement this change? Any links or full answers here are welcome.  I have about 120+ posts already, will this change affect the speed since it's not been done from the start?