.net - C#: Different Ways To Run Code Asynchronously?

Feb 14, 2011

I have this code List<string> myList = new List<string>();

myList.AddRange(new MyClass1().Load());
myList.AddRange(new MyClass2().Load());
myList.AddRange(new MyClass3().Load());
myList.DoSomethingWithValues();

What's the best way of running an arbitrary number of Load() methods asynchronously and then ensuring DoSomethingWithValues() runs when all asynchronous threads have completed (of course without incrementing a variable every time a callback happens and waiting for == 3)

View 4 Replies


ADVERTISEMENT

Ways Of Shortening The Amount Of Code Used, Or Changing It?

May 6, 2011

(I'm using 2010 express), which includes, i think, very basic knowledge of coding. I have made a game in vb 2008 express before and it was a basic arcade game where you move your guy from the left to the right collecting points and dodging enemies that are randomly moving in the opposite direction that you are. Now I am attempting to make a sort-of user interface similar to that of the ps3 home screen, as a windows shell replacement app..

so far i have got what I am looking for in terms of moving between the menus, however the code that I have made seems very extensive for such a thing (in my opinion)..the question I am asking is whether there are ways of shortening the amount of code used, or changing it to be more efficient..if someone is willing to help, I will post my code, or upload my project (if given instructions on how to do so)

View 5 Replies

.net - Upload Files Asynchronously With ASP.NET?

Jul 23, 2010

I'm trying to make an asynchronous upload operation but I got this error message:

Error occurred, info=An exception occurred during a WebClient request`.

Here's the upload function:

Private Sub UploadFile()
Dim uploads As HttpFileCollection
uploads = HttpContext.Current.Request.Files

[code]....

View 6 Replies

C# - Working Asynchronously With GUI Controls In .NET

Jun 22, 2012

I have a listbox of items that need to be processed, and I would like to process them asynchronously on a separate thread. (Never done this before).So I created a Delegate, a Callback, called the method that does the work on the listbox items.

I am getting an exception "System.InvalidOperationException": Cross-thread operation not valid: Control 'ListBoxBlah' accessed from a thread other than the thread it was created on.

Doing the asynchronous operation for individual items doesn't make sense to me because I am only doing it to perhaps perform a large number of operations (the listbox may have 20000 items) in the background while allowing the user to do other stuff.

[Code]...

View 1 Replies

Refer To .net Dll From A .net Web Application Asynchronously?

Feb 9, 2011

I've a vb.net web application where I'm referring to another vb.net dll by adding the reference of the dll and creating the object but after the call it waits for dll to finish operation and return a value before moving forward, is there a way I can do the same job asynchronously.

View 4 Replies

.net - HttpContext Is Not Available - Calling Webservice Asynchronously

Feb 8, 2011

I currently have a web application project that also includes web services within the same project. I currently have a requirement to call the web service asynchronously. Since, I haven't added the web service as a web reference within the same project, I tried to call the web service method using delegates and I see an exception "HttpContext is not available. This class can only be used in the context of an ASP.NET request" when I tried to access the Application property in my web service method call.

[Code]...

View 1 Replies

Event Handlers Processed Asynchronously?

Jun 16, 2009

In VB .NET, when you call RaiseEvent X(), is the function that handles the event X processed asynchronously or synchronously. I was under the impression that RaiseEvent and the processing of the event were Synchronous unless created explictly on another thread. I've been told otherwise though.

View 2 Replies

File Download Asynchronously In WPF Program?

Jun 23, 2010

How do i file download asynchronously in WPF vb.net?

Is there a timer control in WPF?

I am using vs2010 Pro

I need to write an app that downloads a file, uncompresses it, scroll through it and update sql table. Also print labels and invoices.

View 3 Replies

Get Website Asynchronously Using Webclient.downloadstringasync

Jun 7, 2011

I am trying to build a code to get the website asynchronously using webclient.download stringasync..I want to pass the data thus retrieved from dowloadstringcompleted to another function.[code]My problem is that I am not being able to pass on the values as StartDownload gets completed, while data is still being retrieved.

View 8 Replies

Send And Receive An Xml String Asynchronously?

Oct 23, 2010

[code]...

Now i need to do a few hundred/thousand requests all at the same time or atleast over a short period. I am assuning i need to do this asynchronously. I have looked all over the net and tested various ways to communicate asynchronously and am pretty stumped. None of the examples out there seem to explain how i receive the xml return as a string ("which i will write to file or db")

Does anyone have any working code to do such a process?

View 1 Replies

Web Services :: Calling Webservice Asynchronously?

Jan 7, 2011

I am trying to call this webservice asynchrounously in vb.net. So on the aspx side i added this property async="true". Now on the vb.net code side i have this function inside my webservice that i am calling.So -

dim as as webservice.webstring
as.functionasync(param1, param2)

View 1 Replies

[2008] Call A Method Asynchronously?

Feb 16, 2010

im making a transport agent for exchange and am getting hung up on how to call a method asyncronously. Im doing this based on an msdn article but like usual they didnt provide the part of the code i need to figure out.the article is in C# but i converted it to vb in my project. [URL]I know I need to setup a delegate for the method and then invoke that delegate, but im not 100% on how to implement this.

Imports Microsoft.Exchange.Data.Transport.Routing
Imports Microsoft.Exchange.Data.Transport
Namespace TestTransportAgent

[code]....

View 2 Replies

C# - Asynchronously Fired Event Run Synchronously On A Form?

May 17, 2010

[VS 2010 Beta with .Net Framework 3.5]I've written a C# component to asynchronously monitor a socket and raise events when data is received. I set the VB form to show message boxes when the event is raised. What I've noticed is that when the component raises the event synchronously, the message box blocks the component code and locks the form until the user closes the message. When it's raised asynchronously, it neither blocks the code, nor locks the form.

What I want is a way to raise an event in such a way that it does not block the code, but is called on the same thread as the form (so that it locks the form until the user selects an option.)

[Code]...

View 4 Replies

Call The XmlDocument.Load Method Asynchronously?

Aug 31, 2011

I have working code to read an RSS feed that uses:

Dim doc As New XmlDocument
doc.Load("http://...")
Dim channel As XmlElement = doc("rss")("channel")
Dim items As XmlNodeList = channel.GetElementsByTagName("item")

Unfortunately the doc.Load call causes the rest of the program to become unresponsive until it finishes.What's the best way to perform the load asynchronously and have a callback function to process the data?Edit: Here's the code I've tried using WebClient - the Load method is still lagging:

Private Sub checkResults()
'request rss feed
Dim w As New System.Net.WebClient

[code]....

The rssReadCallback method is executed fairly quickly after calling checkResults, but then the UI freezes during the Load method.

View 2 Replies

Get A Javascript Call To Asynchronously Trigger An ASP.NET Event?

Feb 22, 2012

I have a flash video player embedded in a page which has javascript calls for it's controls, specifically calling playStarted() when the play button is pressed. I want to capture this event asynchronously to record when people are actually playing the video versus visiting the page, but I'm not really sure how to do this.

I was thinking the "hack" of a way would be to create a javascript function called playStarted() that would post the video ID to a separate ASP.NET page that would then record it to SQL (where I store my data on page visits and where I want to store my data on video plays.)

But ideally there is a better way to do this where I can register the javascript to the script manager so it can trigger a public sub asynchronously when it's called

View 1 Replies

VS 2008 Call SQL Stored Proc Asynchronously?

Jun 9, 2011

I need to call a stored proc from a .NET web page which takes around 15 min to process. We do not want user not to be able to browse the website in the meanwhile. Is calling it asynchronously the way to go or are there any other recommended ways?

make an asynchronous stored proc call?

View 3 Replies

VS 2010 Update Application Asynchronously Or Synchronously

Apr 6, 2010

I have a program I would like to release, has 2 programs within it.1. The main program. 2. A resource utility.To release it, i'm going to package them both up using a 3rd party setup maker.Now, the question is this.I noticed in the snippets...theres 2 options.Update application synchronously or asynchronously.
First, whats the difference between the 2?Also, could I utilize that so it'll update from the clickonce, so I dont have to keep repackaging it?Also, I want all updates to be mandatory, vs optional like in clickonce default updates..where it gave the user the option to skip.Reasoning is, for cracks, hacks, etc, if it is modified, and i notice cracks, etc. it'll update and replace any cracks, etc. No "skip the update, so the hack/crack continues to work".

View 7 Replies

Upload A Large Excel File And Process Asynchronously?

Jun 27, 2012

I want to upload a large file of tracking numbers and process them into our ordering system.

I used to use Server.ScriptTimeout = 3000

It worked until we upgraded our servers and now it crashes.

I'm Getting This webpage is not available The connection to www.YourSite.com was interrupted.

I could see the .csv file has been uploaded, but many tracking numbers do not get processed.

I'm thinking of maybe switching to a asynchronous update. But I cannot find any good source for it.

If you have any good ideas, please let me know.

View 1 Replies

ASP.NET (VB) Performing A Long Function Asynchronously Without Blocking The Page Thread?

Jan 15, 2012

I've been reading up on asynchronous function / web pages for ASP.NET 3.5 (we're not using v4 yet) but the ones I've seen all focus on performing a background task but then still coming back to finish up and send the response, after the task is complete.

What I want to do is simply kick off the background task (in this case a call to a web service) but then return a response to the browser immediately - ie. without waiting for the asynchronous task to complete. I don't even need to know if it succeeds or not.What is the best way to do that? I can't seem to find examples of kicking off what you might call an "orphan" background task in ASP.NET.

I thought of doing it via a javascript Ajax call on the page I show to the user, but the information passed to the web service is sensitive, so that's out of the question. But that kind of illustrates what I want to do.

[ed] Another idea: Is there an event in the ASP.NET model I can use which occurs after the response has been sent to the browser and the connection closed? ie. So more processing can occur without the user waiting for it?

View 2 Replies

Call A Function In Module And Get Result In The Main Thread Asynchronously

Mar 2, 2011

I have a function in a module that returns a datatable.I need to call that function asynchronously and get the results in the Main thread (Main Form) in vb.net.

View 2 Replies

Game Programming :: Paint Images Asynchronously Using A Background Worker

Dec 15, 2010

All my paint calls are under OnPaint event of the form. my game is getting laggy so i was wondering if theres a way to paint images asynchronously using a background worker.

View 8 Replies

Take Url Given By User From Input Box / Create New Webclient To Handle Download asynchronously

Jun 13, 2012

I'm trying to code a program that can download multiple files at once (on different threads of course).I have created a custom listview component that will allow me to add a progressbar directly to it.What my real question is, how can i take a url given by the user from an input box and create a new webclient to handle the download asynchronously and also report the progress without disturbing all of the other downloads in progress?

View 10 Replies

User Validation - .add And .invoke Being Ran asynchronously And Occasionally Causing Errors?

Sep 2, 2011

I have a bit of code that jumps around a few domains and adds a user to each of them. This follow is a piece of code I had to write to get around the issue of the .add and .invoke being ran asynchronously and occasionally causing errors.

It connects to the domain in question, passing a "CN" from the code in as a search filter but receives a COMException which is normally a LDAP sting config issue. The connection string in this is fine so I am not sure why it is having such a hard time.

Function GetUser(ByVal UserId As String) As DirectoryEntry
Dim objRootEntry As New DirectoryEntry
objRootEntry.Path = "LDAP://DC=SERVER,DC=LOCAL"[code]....

View 2 Replies

Chat System With One Or Two Ways?

Jan 15, 2010

I'm trying con build a simple chat client/software (whole in on executable) wich start listen from the start on the port 5900 and when a client connect to that port the chat is established.

The problem is that only the client can chat to the server, the server cannot answer the client because the connection is working in one way.The i've tried to connect from "server" to the client when it establishes a connection but the system crash warning me that the port is already on use.

[Code]...

View 1 Replies

Delete A File In Many Different Ways?

Nov 14, 2011

What is the difference between these ways to delete a file.Is one of the methods better than the other?Are there other ways to delete a file (. Net 4)

System.IO.File.Delete(path
to file)

My.Computer.FileSystem.DeleteFile(path to file)

View 3 Replies

Different Ways For Playing Audio (MP3)?

Jan 28, 2009

I'm new to VB and have over the last week or two been looking at the different ways to play audio (mp3's). Windows Media Player, Microsoft Multimedia Control, Bass.dll, SndPlaySound, MCI SendString and DirectX (including audiovideoplayback, direct3d and directsound.) I originally decided to use windows mediaplayer, mainly because it seemed the logical choice but quickly found out I couldn't get it to work properly.

So I installed the Directx SDK but now I'm completely overwhelmed about what to use and why. I need to be able run the compiled code on a win 2k box, play an mp3 from start to finish then load and play another mp3 from start to finish and so on. Whats the difference between the varied choices and which would be the best for me to use?

View 5 Replies

Different Ways To Create Object

Jun 13, 2011

I want to know by how many different ways I can create an object. The most common usage I am aware about is:
Dim obj as ClassA = new ClassA().

View 1 Replies

Different Ways To Declare Variables?

Aug 20, 2009

I'm new to VB.NET programming.What I'm confused about is the different ways one can declare a variable.Would someone please explain the difference between the two declarations below? [code]

View 2 Replies

Different Ways To Play Audio?

Dec 10, 2009

I'm new to VB and have over the last week or two been looking at the different ways to play audio (mp3's). Windows Media Player, Microsoft Multimedia Control, Bass.dll, SndPlaySound, MCI SendString and DirectX (including audiovideoplayback, direct3d and directsound.)I origninally decided to use windows mediaplayer, mainly because it seemed the logical choice but quickly found out i couldn't get it to work properly. So i installed the Directx SDK but now i'm completely overwhelmed about what to use and why.

View 3 Replies

Different Ways To Sending Emails Using .net?

Jul 14, 2009

What are the different ways to send the emails using vb.net?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved