I'm trying to implement a snippet where we can loop through a dynamic list of objects.   using System; using System.Collections.Generic;  public class Program {     public static void Main()     {         var l = new List&lt;int&gt;();         l.Add(1);         l.Add(2);         l.Add(3);         l.Add(4);      foreach(var i in l){         Console.WriteLine(i);            if(i==3){             l.Add(5);         }      }  }  }   This is throwing below run time error.  1 2 3 Run-time exception (line 15): Collection was modified; enumeration operation may not execute.  Stack Trace:  [System.InvalidOperationException: Collection was modified; enumeration operation may not execute.]   at Program.Main(): line 15   Any help is appreciated. Thanks.
I can't get to the bottom of this error, because when the debugger is attached, it does not seem to occur.  Collection was modified; enumeration operation may not execute  Below is the code. This is a WCF server in a Windows service. The method NotifySubscribers() is called by the service whenever there is a data event (at random intervals, but not very often - about 800 times per day). When a Windows Forms client subscribes, the subscriber ID is added to the subscribers dictionary, and when the client unsubscribes, it is deleted from the dictionary. The error happens when (or after) a client unsubscribes. It appears that the next time the NotifySubscribers() method is called, the foreach() loop fails with the error in the subject line. The method writes the error into the application log as shown in the code below. When a debugger is attached and a client unsubscribes, the code executes fine. Do you see a problem with this code? Do I need to make the dictionary thread-safe? [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single)] public class SubscriptionServer : ISubscriptionServer {     private static IDictionary&lt;Guid, Subscriber&gt; subscribers;      public SubscriptionServer()     {                     subscribers = new Dictionary&lt;Guid, Subscriber&gt;();     }      public void NotifySubscribers(DataRecord sr)     {         foreach(Subscriber s in subscribers.Values)         {             try             {                 s.Callback.SignalData(sr);             }             catch (Exception e)             {                 DCS.WriteToApplicationLog(e.Message,                    System.Diagnostics.EventLogEntryType.Error);                  UnsubscribeEvent(s.ClientId);             }         }     }          public Guid SubscribeEvent(string clientDescription)     {         Subscriber subscriber = new Subscriber();         subscriber.Callback = OperationContext.Current.                 GetCallbackChannel&lt;IDCSCallback&gt;();          subscribers.Add(subscriber.ClientId, subscriber);                  return subscriber.ClientId;     }      public void UnsubscribeEvent(Guid clientId)     {         try         {             subscribers.Remove(clientId);         }         catch(Exception e)         {             System.Diagnostics.Debug.WriteLine(&quot;Unsubscribe Error &quot; +                      e.Message);         }     } }
Will my software work on the next version of Windows I have some software and I'd like to know if it works on the next version of Windows (Windows 10). GRUB and LILO both fail to install to NVMe hard disk when installing Debian Storing the original document class page layout with geometry In a semiconductor memory chip, each bit of binary data is stored in a tiny circuit called a memory cell consisting of one to several transistors. Volatile type.   Suppose an application stored its data in a particular segment on the computers RAM.  How would the CPU know what data to extract and how would it sort through the other data to get to it. If everything in its core level is 0 or 1 its hard to distinguish what purpose 'x' memory has. Currently I am using Outlook 2010, and sometimes customers claim that they will received an attachment in Windows.dat format.  I have searched online for possible solutions, but mostly the suggestion is to change the sending format to plain text. However, by using plain text format, there is some limitation.  So I just wonder, besides the plain text format, is there a ways to solve the winmail.dat issue?  Besides, does plain text format really 100% avoid the issue? Converting string into datetime I've got a huge list of date-times like this as strings:  Jun 1 2005  1:33PM Aug 28 1999 12:00AM   I'm going to be shoving these back into proper datetime fields in a database so I need to magic them into real datetime objects.   This is going through Django's ORM so I can't use SQL to do the conversion on insert. :  Not ten minutes ago, I received this error, twice:  And also an &quot;Oops, something bad happened&quot; error.  I'm also getting question posting errors.  Can we fix this, please? Decomposition of the tensor product $\mathbb{Q}_p \otimes_{\mathbb{Q}} \mathbb{Q}[i]$ into a product of fields I am trying to solve the following problem:     For each rational prime $p$, describe the decomposition of the tensor product $\mathbb{Q}_p \otimes_{\mathbb{Q}} \mathbb{Q}[i]$ into a product of fields, where $\mathbb{Q}_p$ is the field of $p$-adic numbers.    I know that the tensor product of $2$ extensions of a field one of which is finite is Artinian and is therefore a product of Artinian local rings, but I do not know how to compute these Artinian local rings. Please if you can help me with this, I'll really appreciate it. Uninstalling Ubuntu from dual boot / changing bootloader Efficient Way to store images in android Sending a JavaScript variable to a PHP function I am trying to send a value in JavaScript variable to Drupal. I am calling an external js file in hook_nodeapi(). I want to send a value from this external js file to Drupal, and want to use this value in Drupal in hook_block. For example  hook_nodeapi() {   // call(external.js) } external.js var sendData =10;  hook_block {   case view:   // need to access sendData value }   I tried this using cookies, but I think that is not the best way. How can this be done? Find the volume common to two circular cylinders, each with radius r, if the axes of the cylinders intersect at right angles. (using disk/washer) Find the volume common to two circular cylinders, each with radius r, if the axes of the cylinders intersect at right angles. (using disk/washer)  I saw no example of this problem anywhere.. I saw an example how to solve it without calculus but I'm afraid that'll be deductions on my test.. I have the volume of a cylinder and the method of area between two curves but this is out of my reach.... I don't know what I can try... Can anyone tell me how Google decides which image to use when it shows an image with the search results (as is the case with mobile search, sometimes)?  If you look at these mobile search results …    … and take the AliExpress.com result as an example, by inspecting  you can see that  used by Google seems to have no special declaration, etc. It is just the first JPG that appears in that page's HTML - so I was thinking maybe that's why it's the image that is used in the Google search results.  However, when you look at these mobile search results …    … and consider the Backpack Billboards result,  reveals that  being used is actually the seventh image declared in the HTML.  So can anyone shed any light on how Google determines which image to be displayed? I would like to know so I can then have control over which image is displayed for my site.  Update / Solution  Thanks to the answers, below, this is the code I have now added to my head HTML in order to get the thumbnail shown in Google when searching for backpack billboards:  &lt;script type="application/ld+json"&gt; {   "@context": "http://schema.org/",   "@type": "Product",   "name": "Regular Backpack Billboard",   "image": [     "https://backpackbillboards.com/wp-content/uploads/2017/12/backpack-billboards-1x1.jpg",     "https://backpackbillboards.com/wp-content/uploads/2017/12/backpack-billboards-4x3.jpg",     "https://backpackbillboards.com/wp-content/uploads/2017/12/backpack-billboards-16x9.jpg"    ],   "description": "Backpack Billboards feature a rechargeable battery which powers the internal LED lights providing a bright illuminated display for up to 8 hours.",   "sku": "BPBB8",   "brand": {     "@type": "Thing",     "name": "Backpack Billboards"   },   "offers": {     "@type": "Offer",     "priceCurrency": "USD",     "price": "299.00",     "priceValidUntil": "2020-11-11",     "itemCondition": "http://schema.org/NewCondition",     "availability": "http://schema.org/InStock",     "seller": {       "@type": "Organization",       "name": "Backpack Billboards"     }   } } &lt;/script&gt; Login as other user setting for other profile except System Adminsitrator If a user is setup as System Administrator profile, the user can login as other user. However, is there any option that I can enable this function for other profile except System Administrator because I don't want to give them other System Administrator permission access?  In the past as I remember in summer 12, there's an option called "managing user permission" which allow me to disable or enable the profile to login as other user. But I don't see this anymore. What is the relationship between UV image and material texture? I am struggling to understand perhaps a very simple concept in Blender. There are materials which might have some diffuse coloring and a texture image, and there are also UV maps with their own images. Both can be applied to meshes or faces, but it seems that if a face has UV map then the material's texture is ignored and an image for UV map is picked.   If so, what is the use for a texture in a material if it is replaced by UV map's image?   EDIT: I've added some images to clarify the issue I have.   Case 1: a basic plane with material which has a texture, and no UV map. Diffuse color is applied, but material's texture is not.   Case 2: like above, but with reduced intensity of texture.   Case 3: Added UVmap and added image to the UVmap. Now I have texture, but not the diffuse color, and if UVmap was a different image, it would be picked regardless of texture set in the material.   So if I have UVmap image, what is the material texture for? What kind of capacitor could build up, and maintain a charge acquired from lightning? What was the purpose of banning use/development of cloaking technology in Treaty of Algeron? The  prohibited the development or use of cloaking technology by the Federation. This treaty was a peace treaty and use of cloaking technology in one's own space couldn't disturb peace. Plus, the Romulans already had cloaking technology, so banning it was unfair for the Federation. So, why was this ban introduced?  Another thing: There were many things to ban, but why cloaking technology? Making an MFC application international I've got several large MFC applications here, and converting them into any other format is out of the question.  We're expanding into other markets, and would like to make the apps work in other languages and cultures.  So far, I've found occasional references as to what to do with Visual C++ version 6, with one mention that later versions of MFC have additional relevant features.  Searching MSDN gives me instructions on how to convert the apps to Unicode, which we already did.  I found nothing on MSDN on how to make languages multilingual once they're in Unicode, only a few older things using Google, and one book about internationalization using VC++6.  (We're using Visual Studio 2008 now, on XP and Vista.)    I make no claims for the strength of my Google-fu, and would be happy to be directed to things I've missed.  Is it reasonable to use the methods of VC++6, or should I use later features?  If I should use features later than that, where can I find some reference to them?  Is there something I should worry about other than setting the locale, converting all strings to resources, and duplicating resources in different languages?  I can find more things about .NET internationalization, but I'm inexperienced in .NET.  What will I find there that's applicable to VC++ and MFC?  Edit:  I just ran into difficulties trying to put Unicode strings into the String Table resource.  (As far as I can tell, Unicode strings need to be entered into the .rc file with a text editor, in L"0x0034" form.  I haven't found a resource editor way to do that.)  Any tips on that?  Any other resource I can use in VS2008 using VC++ and MFC?  Edit:  Somebody on a Microsoft forum suggested that I open the offending .rc file in Notepad, and save it in Unicode.  Unfortunately, this doesn't seem to fix the dialogs, although the stringtable seems to be working in Japanese. What's a concise way to check that environment variables are set in a Unix shell script? I've got a few Unix shell scripts where I need to check that certain environment variables are set before I start doing stuff, so I do this sort of thing:  if [ -z "$STATE" ]; then     echo "Need to set STATE"     exit 1 fi    if [ -z "$DEST" ]; then     echo "Need to set DEST"     exit 1 fi   which is a lot of typing. Is there a more elegant idiom for checking that a set of environment variables is set?  EDIT: I should mention that these variables have no meaningful default value - the script should error out if any are unset. How to get a normal application menu in the top- or titlebar in Gnome