Build A Class Structure To Support Two Threads?

Nov 8, 2009

I have this application that users can make exams that contain exercises of different ... whatever. Anyway when student takes the exam he chooses it from a list and then all exercises are loaded from database. I wanted to make loading process faster by loading only first exercise data and putting others in background thread.

Actually in other parts of this application something like that is done but not by me. Basicaly an api class is built around BackgroudWorker and i can use this class to put certain functions of objects to be executed in background. The idea sounds great but in real life there are some problems with it. For example for historical reasons this application uses global functions and reader and uses global connection to Access database which means if in background something is being fectched from data base and you try to fetch from database in main thread then a „reader is already open" error occurs. To avoid this error if im doing something in main thread and want to fetch some data i have to move my function from main thread into background worker function list. And basically this in my opinion stinks cuz you end up with many delegātes, invoked checking and thre result... I was just thinking that there maybe is another way to allow (maybe with events) not put everything in background in case something is happening in bakcground but rather allow bgworker to finsih current thing, then do my thing and then resume bgWorker and not create havoc in code.

Basically i have to classes - exam and exercise that each implement many interfaces (like IExercise, IExerciseResult, IExerciseYesNo, IExerciseMultipleChoise etc.)And then i have DataBase classes like ExerciseDB, ExerciseResult etc. That have functions that preparē the sql params and call sqlHelper functions.And for example when i load up exam i go throug all exercises and call LoadData function that in turn calls ExerciseDB function selectData and then i put the returned data in Exercise object. And this type of thing of course would producē error if i at the same time would try to register the answer in database for another exercise. Ofcourse i could always check and put this in background... but as i said i'd rather want to work with database from both threads.

View 13 Replies


ADVERTISEMENT

If Compile A VB6 App On Win7 - ADODB.Connection Errors With "Class Does Not Support Automation Or Does Not Support Expected Interface"

Apr 28, 2011

I compiled some VB6 code on my Win7 x64 machine and the result .exe will not run correctly on any other machine. VB6 code is just a new template .exe file with one button, a reference to "Microsoft ActiveX Data Objects 2.6 Library" and the following code in the button press event: Dim db Set db = New ADODB.Connection It runs correctly on my machine, but no others (even other Win7 x64 machines) (Update: I found TWO other users where it runs and one of them is Jeff Atwood!, but most machines have the same problem)

[Code]...

View 2 Replies

Build Own Unique Web Browser Without The Support Of Internet Explorer?

May 12, 2009

I made a web browser in VB 2008. Does creating a web browser in VB 2008 require Internet Explorer to be installed? If so, than how can i make it so that I build my own unique web browser without it needing the support of Internet Explorer.

View 3 Replies

Class Structure - Large Structure That Has Lots Of Properties ?

Jan 5, 2010

I'm new to VB 2008 after having spent a long time with VB6, so I apologize if this is a stupid question. But I'd really like to have this straightened out.

Let's say I have a pretty large structure that has lots of properties.

Code:

Now say that I want an internal database with about 10 instances of this structure total, describing, say, 10 different products that a store sells. When these values are loaded from a database, they remain totally static. (However, they can be different each time a program loads)

Now say that I have a class. Each instance of this class is a type of that BaseProduct structure. Meaning, each instance of the class pertains to one of the 10 types of products that the store sells. However, this class has additional properties that pertain specifically to each instance, which are not static.

Code:

Now, the problem here is... If I have 200 different transactions, each one contains an instance of BaseProduct. BaseProduct is HUGE, and is largely redundant (only 10 types possible), so I think it's a little silly to include a whole copy of it with EVERY transaction. However, the Transaction class really needs information regarding the base product it pertains to. Is there a way to, instead of declaring a New BaseProduct in the Transaction class, to simply make one of the properties of the Transaction class a pointer to a BaseProduct variable?

In VB6, I would accomplish this by making a BaseProduct(10) array, and then giving each Transaction an ID number referring to an entry in that array. But in VB 2008, using class structure, this is impossible. I can't define the BaseProduct(10) array outside of a class in a namespace, and if I define it in the actual application's form, then the class loses modularity since it relies on the application that's using it.

View 11 Replies

VS 2008 Convert The XML Structure Into A Class Structure?

Apr 25, 2010

I'm having a problem that's driving me crazy; I can't understand how to convert the XML structure into a class structure (that I want to use to hydrate a XML document).

The XML document looks like this:

xml
<?xml version="1.0" encoding="utf-8"?>
<artists xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">

[code]....

View 2 Replies

Passing A Structure From One Class To Another Class In A Applications (VS2008)

Apr 7, 2010

I'm sure there are several ways of achieving my goal but I am after opinions on what you think is the best option. I'm writing a vb.net application which (amongst other thinks) interfaces with media players in the home. Because there are different types of media playersI'm trying to structure it so each type of media player has it's own class which interfaces to a management class which sits on top of all the different devices types.

The device classes are responsible for discovering the phsyical devices and returning that information up to the management class. A device class may be responsible for monitoring 1 or more physical devices so..

[Code]...

View 1 Replies

Threads In .vb Class Not Working For Web App

Feb 11, 2010

I have a web app that I'm writing in asp.net, with vb code behind. The threads were working well when I had all my code in the aspx.vb code behind files, but after I moved the code into a seperate Class.vb file, the threads don't seem to be working in parallel any more. Below is a small section of my code.

It used to be that when the "botThread.Start()" method was called, the page would redirect to success.aspx, and work on the SQL query (RunBots()) thread in the background. Now when botThread.Start() is called, the page doesn't redirect to success.aspx until AFTER the RunBots() sub has been completed.

View 2 Replies

Runtime Error - Class Does Not Support Automation

Aug 11, 2011

I created a simple VB 6 executable that runs fine on my computer (Windows 7), but when I deploy it to another Windows 7 PC or a Windows 2003 server, I get the error:
"Runtime Error 430: Class does not support Automation or does not support expected interface".

The code
Private Sub cmdStart_Click()
Dim rstLogin As ADODB.Recordset
MsgBox ("Before first recordset")
Set rstLogin = New ADODB.Recordset
MsgBox ("After first recordset")
End Sub

The line that generates the error is " Set rstLogin = New ADODB.Recordset". I had a coworker compile it from his Windows 7 pc and run it on other machiens and it works fine. So I believe it's an issue with my pc config.

View 4 Replies

.net - Update From From Multiple Threads Of The Same Class?

May 31, 2012

I have this class and I have a loop that launches multiple threads from the same class. This is all done from the main form.Now I want to update the richtextbox on the main from these classes.I have tried those begininvokes etc etc and nothing worked, no error but no output as well.Here the code for launching the threads :

Private PingObjects(100000) As Account 'Account is the class and login is the sub in it...
PingObjects(I) = New Account
Threads(I) = New Threading.Thread(AddressOf PingObjects(I).login)

[code]....

And to update the rtb, im using MainForm.log.text = "....." Nothing happens, no error.I have tried using the begin invoker method as well.

View 2 Replies

Value Of That Object Internally Within My Class From Different Threads?

Oct 22, 2009

Lets say I have got a class level boolean, defined like so:

vb Private _ServerRunning As Boolean = False

and it is exposed like so:vb Public ReadOnly Property ServerIsRunning() As Boolean
Get
Return _ServerRunning
End Get
End Property

Do I need to worry about thread safety when modifying the value of that object internally within my class from different threads?

View 4 Replies

VS 2005 Converting Class To Use Threads?

Mar 29, 2010

I have a class that includes a timer :-

public class clsQueryObject
private tmrPoll as new timer
Public sub New()

[code]....

View 3 Replies

VB 6 Runtime Error Class Does Not Support Auto-mation?

Jul 8, 2011

I created a simple VB 6 executable that runs fine on my computer (Windows 7), but when I deploy it to another Windows 7 PC or a Windows 2003 server, I get the error"Runtime Error 430: Class does not support Automation or does not support expected interface"

View 12 Replies

Asp.net - Structure A Class Inside A Class?

Jun 3, 2011

Currently, if I have different classes containing functions etc, I would structure them all in the 1 VB file titled whatever the main Class is. For example:

[Code]...

However, the problem with this is the file can become 1000s of lines long making hard to find portions of code. Is there a way I can store SubClass in a file such as MainClass.SubClass.vb so that its easier to locate classes? Or is there a better, more standard, way of doing this?

View 3 Replies

C# - Does Queuing Threads Impact Non-thread Safe Objects In The Same Class

May 23, 2011

c# - Does queuing threads impact non-thread safe objects in the same class?

View 1 Replies

Does Queuing Threads Impact Non-thread Safe Objects In Same Class

May 7, 2009

If I spawn a thread with ThreadPool.QueueUserWorkItem and that thread does not reference the object that is not thread safe, would it compromise that non-thread safe object? By not thread safe object, I mean a third party interface to a programmable logic controller that has no ability to open simultaneous connections or concurrency support.I suppose I just wanted to be sure that by queuing threads in the same class as my reference to that object, I wouldn't somehow be compromising its thread safeness in a way I didn't realize.

View 2 Replies

C# - Use A Structure Rather Than A Class?

Apr 10, 2009

In a recent project I was working I created a structure in my class to solve a problem I was having, as a colleague was looking over my shoulder he looked derisively at the structure and said "move it into a class". I didn't have any argument for not moving it into a class other than I only need it in this class but this kind of falls down because couldn't I make it a nested class?

View 5 Replies

.net - Where To Keep A Structure: Class, Module Or None

Apr 18, 2011

This is purely a coding practice question concerning VB.NET structures. Where do you keep one?As an example, I've created a structure for the simple purpose of keeping information organized, I'd like this structure to be stand-alone, not belonging to any class so I wouldn't have to access it through SomeClass.MyStructure but rather simply MyStructure. So, do I keep it in a separate class and import it into my namespace? Do I keep it in a module (Static class, essentially)? Do I just make a separate VB.NET code file and place is there (I would like it to live in a separate file). Just to clarify, I need this structure to be accesses by the whole application, not just a single class.

View 1 Replies

Class Structure For Three Outputs?

Feb 20, 2012

Could someone write me a Class structure for passing the data array below.

Function function1(Byval input1 as Double, Byval input2 as Double, Byval input3 as Double)
'code'
data.data1=value1

[code].....

View 4 Replies

Build My Own Class Library?

Oct 18, 2009

Can I create my own class library, possibly to be sold commercially, in VB.NET?

View 2 Replies

Cannot Get Values From A Serializable Class And Structure

Feb 17, 2010

I have a serializable class and structure I created for an ArrayList to be access within a Web Application. The problem I am having is the count comes back as zero after calling New. I debugged the code and the Arrylist is being populated

View 3 Replies

Class/structure To Serialize JSON?

Mar 9, 2011

I am trying to figure out a class/struture to handle the following JSON format:

{
"ReturnData": [
{
"id": "msg2DoesNotExistName",

[Code]......

I may or may not have Data for ReturnData and SetValue (one or both at a minimum). I am trying to let the serializer handle most of the formatting without having to check for empty sections and single-item arrays.

View 1 Replies

Possible To Show Structure Of A Class In A Treeview?

May 31, 2009

is it possible to show the structure of a class in a treeview? if yes how

View 3 Replies

Reflection On Structure Differs From Class?

Jan 15, 2009

Code snippet:

Dim target As Object
' target gets properly set to something of the desired type
Dim field As FieldInfo = target.GetType.GetField("fieldName", _
BindingFlags.Instance Or BindingFlags.Public Or BindingFlags.NonPublic)
field.SetValue(target,newValue)

This snippet works perfectly IF target is set to an instance of a CLASS.However, if target is set to an instance of a STRUCTURE, the code does not actually change the value of the field. No error, but the value remains unchanged.And, oddly, if I'm stepping through code, watch the SetValue fail to do anything, and immediately go to the Immediate window and type exactly the same SetValue operation, that works.

Edit:

Per request from Jon Skeet, actual code:
Private Shared Function XmlDeserializeObject(ByVal objectType As Type, _
ByVal deserializedID As String) As Object[code].....

View 2 Replies

[2008] Size Structure In A Class?

Mar 6, 2009

I am making a class that has a property that I want to be of type System.Drawing.Size. I don't seem to be able to reference system.drawing from within my class, and therefor can't set my property's data type to Size. Anyone know how I might do this?

View 2 Replies

Build A Class That Works With A Form?

Sep 7, 2010

I am trying to build a class that works with a form, but I keep getting the dreaded "Object reference not set to an instance of an object" Error.The form basically collects test grades and assigns them to a collection.My class code is as follows:

Public Class Scores
Private colScoreCollection As New Collection
Public mintSum As Integer
Public mdecAverage As Decimal
Public mintMinimum As Integer

[Code]...

I had a similar project I was working on that had a collection in it, but now that one is giving me the same error. It there something with my version of Visual Studio that is causing this error possibly?

View 7 Replies

Build A Useful Class And Implement It In An Application?

Apr 16, 2009

I am trying to build a class. I am having a difficult time conceptualizing how a class is built and how it works. I want to be able to build a USEFUL class and implement it in an application.

View 1 Replies

Class - Internationalization In .Net : Choosing The Right Structure Type?

Jan 22, 2010

I'm about to start translating my vb.net application, and I don't want to use the default methods provided by Visual Studio to do so. I need my application to be very light, and it nearly doubles it size to use the resources option.Therefore, I'm planning to use some thing like a class, of which I would have one instance per language. Since I don't want to distribute language files as separate files (I'd rather have them hard-coded), I would like to find an easy way to check if every field of the class is initialized. I was thinking of something like an Interface, where I would do something like this:

Public Interface Language
Dim HelloMsg As String
Dim GoodbyeMsg As String
End Interface

[code]....

It's obviously not the right way to do it (although I could use properties instead of vars), but I was wondering whether the was a way to have the compiler check that everything is translated and warn about it if not.

View 2 Replies

Create A List(of Bytes) Within A Class Structure?

Sep 2, 2011

I have the following Structure within a class[code]...

How do I efficiently use this list?[code]...

View 1 Replies

Creating A Lot Of Class And Structure Types For A Project?

Oct 12, 2009

Is there any performance hit (or other problem) to creating a lot of class and structure types for a project? I'm not talking about the number of objects existing in-memory during runtime; rather just defining a lot of object types during design time. I find myself making a lot of small classes and structures that are little more than simply packaging a few related variables together.

View 4 Replies

Measurements Unit Conversion - Structure Of Class

Sep 14, 2011

I'm working on a Unit Conversion Module. I've found several good ideas here, as well as on CodeProject. My code looks very similar to this C# code at
(url)

From the following you'll probably gather that I'm pretty new to programming.I've created a Units base class that I inherit to create each unit type.[code...]

I need to create several different Unit types, such as Length, Pressure, etc. This is working well except for one issue. I'd like to be able to change the UnitType, and automatically update the UnitValue. Such that if the Unit object has a value of 1 and a type of Inch, and the type is changed to Cm, the value would update to 2.54.

Something like this.... I've seen examples of this, but the difference here is that, I can't specify the Covert function in my base class because it changes with each new UnitClass I create.
[code...]

I tried making the Property UnitType Overridable and creating a new Override Property for UnitType in each UnitClass that I created, but I failed to get that to work.

View 1 Replies







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