I recently changed a For Each loop to a Parallel.ForEach loop. I'm concerned about an object being declared outside the loop but assigned while iterating in the loop. Here is the simplified code.
Dim results As ModelResults
Dim noResultsModel As New List(Of ModelResults)
Dim lock As New Object
Parallel.ForEach(_modelEngines,
Sub(model)
[Code]...
Is there a potential race condition with the results object? Would anything be different if I moved the declaration of results into the for loop?
I've been trying to follow the examples I've found online and, well, I can't really get my head around what I've done wrong.So, I have a simple piece of code to search for a machine in AD, as so. [code]
I need a simple method for a user to enter as many rows of data as they wish (probably won't exceed 50 in most cases and that's pushing it) and then store that data for retrieving the next time they want to reuse that list. I will also need to read the rows in for manipulating text in a file with those entries.
Would the best method to be to use the DataSet in VB Express 2008 and then use the DataGridView for allowing the display and entry of the data?
I want to resize the resolution of an image before uploading it to local storage. Right now it saves the image in its full resolution and I have to manually resize it using width="200" height="200" or a css tag in aspx. I want to reduce the file size of an image before storing it, hence by resizing the image resolution when the user uploads it via button. I've tried using System.Drawing before and setting the int imageHeight and int maxWidth to be resized but couldn't seem to get it to work.
My code so far is: Protected Sub btn_SavePic_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btn_SavePic.Click Dim newFileName As String Dim SqlString As String [Code] .....
I've been reading a lot of articles here and there, really, for the past two days, searching for a good local storage system. I have no immediate use for now, so I am just exploring my choices. By saying 'local storage system,' I'm talking about some sort of database used for applications that let users manage and organize personal accounts (bank accounts, web site accounts, application licenses...). I do use XML to store user settings. But if you have to manage lots of information locally, XML won't probably be good enough, I'm afraid.
So what are choices Visua Basic users? Well, as I often mention, I develop Mac software products. And I use SQLite. In fact, every one of some 40 apps sold at Mac App Store uses SQLite for good reasons. I know that you can use SQLite with Visual Studio after installing a package from sqlite.phxsoftware.com. But I don't know if your application can reproduce a database file when necessary. That being said, I'm looking for a system that I can use to create a file programmatically especially when the user launches it for the first time. So what do you use to locally manage large information? SQL Express? SQLite? XML?
I have a service that scans network folders using a parallel.for method. However recently I am finding if I stop the service then while windows says the service is stopped the process is still running in task manager. However it is at 0 cpu and the memory does not change. If I try and end the task (even a force in command prompt) it just says access denied and i have to reboot the server. What would be the best way to make sure everything terminates? I thought of adding a global Boolean that in the stop procedure it turns true and part of my parallel code will check for that and call s.stop.
Does anyone know how this can be done? The problem is that when you run the script to add a domain user to the local group as a local user you have no permissions to query the domain. Is there a way to pass a user name and password when doing this? [code]...
My co-worker said that in a previous interview, he learned that foreach is faster in VB.Net than c#'s foreach. He was told that this was because both have different CLR implementation.
Coming from a C++ perspective, I'm curious on why this is and I was told that I need to read up on CLR first. Googling foreach and CLR doesn't help me understand.
Does anyone have a good explanation on why foreach is faster in VB.Net than in c#? Or was my co-worker misinformed?
I have searched high and low for documentation on how to use this feature. While the loop I could write would be simple and take no time, I really would like to learn how to use this. Basically I have a class, say, Widget, with a Save() sub that returns nothing. So:
Dim w as New Widget() w.Save()
basically saves the widget. Now let's say I have a generic collection List(Of Widget) name widgetList(Of Widget) and I want to run a Save() on each item in that list. It says I can do a
widgetList.ForEach([enter Action(Of T) here])
....but how in the F does this work??? There is no documentation anywhere on the intrablags.
I'm writing a loop to go through the first array of a 2D loop, and I currently have it like this:
For Each Dir_path In MasterIndex(, 0) 'do some stuff here Next
But it's giving me an error, saying it expects an expression in the first field. But that's what I'm trying to do, loop through the first field. How do I fix this? What would I put in there?
EDIT: to clarify, I'm specifically looking for the 0th element in the subarray of each array, that's why that second field is constantly 0.
What i'm doing is getting values from some html, i use a regex to retrieve all the fields, but there are some fields brought back i don't need (4 out of 11) i know the names of these fields, but was wondering if there was a way i could filter out the ones i don't need in the foreach:[code]
I'm flummoxed I'm using VB.Net, Linq, and a DataContext. My DataContext contains a table 'transactions'.
I first declare an IQueryable(Of transaction) and assign it to nothing. I build a predicate in a foreach loop and use a transactions.Where(predicate) to assign the IQueryable a value. If I do an IQueryable.ToList(), I get a number of items in the collection.
However, on the next iteration of the loop, the IQueryable.ToList() gives me 0 items.This is driving me crazy. I tried to use the LINQ to SQL Debug Visualizer with VS2010, (I recompiled the 2008 version with the new reference) but no dice - I can't see the SQl generated or what's inside the IQueryable.
I am making a program that automates the seperation of a csv file. We read the csv in through and then assign the "line" using a split command to an array. After that we go through each "cell" in the array and put an = in front because this causes leading zeros not to be lost. Here's the code.
arLine = line.Split(replace) For Each cell As String In arLine cell = cell.Replace(",", "") cell = String.Format(cellFormat, cell) Next
arLine is the array and replace is the delimiter, in this case a pipe not that it matters.'
When it goes through, the arLine is correct but the values in each cell are not changing, any thoughts? newer to VB.net and need direction
I am having an issue extracting the value from every row in column "MobileID" within a table named "dt" that is within a dataset named "ds".Here is how the dataset and datatable are created.[code]
I have the following for each loop which loops through a registry key and reads all the values:
Dim returnValue As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWAREMicrosoftWindowsCurrentVersionRun") Dim keyname As String = "HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionRun" Dim values() As String = returnValue.GetValueNames
[code].....
What I am trying to have been highlighted in bold.. Each time the loop executes and reads a value from the registry, I want the code to create a checkbox which has a unique name and text according to the value that was read... So the number of checkboxes will depend on number of values that is got from the registry...But this doesn't work. It only creates one text box and the text of the textbox is also incomplete...
Everything is working fine except for one part. The part where the second foreach loop runs. If I only have one plugin installed it puts 2 entries in the list. The reason is because it has 2 rows and it is adding it twice. I know what the issue is I just am drawing a blank right now.
I can't seem to get the syntax right for a simple Parallel.Foreach Loop.
This is how I would normally iterate a SearchResultCollection
Dim src As SearchResultCollection = DSearch.FindAll For Each x As SearchResult In src Debug.WriteLine(GetProperty(x, "Name")) 'Parallel.ForEach(x, Function(x) Debug.WriteLine(x)) Next
As I have (obviously) misunderstood it this should be the syntax for the Parallel.Foreach
Parallel.ForEach(src, (Sub(x As SearchResult) GetProperty(x, "Name"))) Parallel.ForEach(src, Function(x) Debug.WriteLine(x)) It's not that though. What's the correct syntax here?
I have a form called frmMapViewer. In this form I 25 labels showing districts of my country. think I want to assign names(text property) to each label.[code]...
Why there is only a static/shared version of ForEach for arrays? IE: ForEach<T>(T array[], System.Action(Of T) action[]) I assume this has something to do with the type inference requirements of implementing an instance method, but when you declare your array you provide type right?
How to write xml foreach datarow in dataset? I have dataset with 5 record in table, i want write to xml file with 5 xml file. in one xml file have one record.