|
A BackgroundWorker would give similiar function, but I have several more events that BGW supports. And although I probably could inherit a class using BGW, I'd really like to learn the methodology myself and incorporate it into my objects.
|
|
|
|
|
smarrocco wrote: Is there something like this that can be done that the raised events are always running in the context of the main form that created the ProcessUtility_Class object in the first place? You "could" pass a reference of one of the controls of the main-thread to the worker-thread. That way the control "could" do the invoke. You'd do a myForm.Invoke() from the worker-thread.
..and then you'd be tearing your hair out, trying to fix the "object is already disposed" exceptions; your thread will still be executing when the mainthread starts disposing of stuff.
So, I used IlSpy to look at the code from the backgroundworker, and it's using a neat trick;
AsyncOperation.Post[^]
"Invokes a delegate on the thread or context appropriate for the application model."
Will (probably) try it out in the weekend
--edit
There's a how-to here[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
modified 31-Mar-14 14:22pm.
|
|
|
|
|
Hello !
I'm using VB.net 2013 and sql server 2008R2
I'm using SMO for backup and restore databases.
I have some questions :
1. When I backup a database with SMO , the size of backup file is larger than size of backup file created with SQL server management studio. Why ?
2.If I want to restore a backup file , how can I test first that this is a valid backup file for my application.
Thank you !
|
|
|
|
|
1. SQL Server can create compressed backups
2. Run the restore using the VERIFYONLY[^] option - this will test the backup file without actually doing the restore
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Thank you !
1. But using SMO is possible to create compressed backups? If yes , How can I do that ?
2. I want to check if this backup is compatible with my program , and has the tables structure that use my program.Is possible to do a check before restoring process ?
Thank you !
|
|
|
|
|
1. What is SMO?
2. I doubt that you can do this directly from a backup file - you would need to restore it (probably under a temporary name) and then examine the structure, which you could do programatically
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
SMO :SQL Server Management Objects (SMO) are objects designed for programmatic management of Microsoft SQL Server
|
|
|
|
|
1. The backup object has a CompressionOption property[^]
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
2. You may be abloe to get content information using the ReadBackupHeader method[^]
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
dilkonika wrote: But using SMO is possible to create compressed backups? SMO and SQL are two ways of doing things, but the features remain the same. The SQL Command[^] offers the same. The big advantage of SMO would be intellisense.
I'd suggest you write an article (for CodeProject) explaining the advantages and disadvantages of both. Seems you'll need to research it anyway
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hello,
I am stuck and need some advice.
I am using a DataGridView to store CSV data and then using Zedgraph to display this data. Most of these values in the CSV are numeric and I have no problems with these but I have several items in the CSV that are text and display a change of state from on/off, open/closed, active/inactive, etc..
I have been trying to work out a method to have Zedgraph handle these digital On/Off states. I can convert the values to 0 and 1 to represent the states and that seems to work okay but I still need to have a text description for these states so the user can see the actual state or condition of the circuit.
Is there some way that I can assign both, for example display something like Open(0) / Closed(1) and have Zedgraph use the numeric values?
Thanks
|
|
|
|
|
Hello,
I am beginner and I have the following problem.
I have installed:
- Visual Basic 2010 Express
- Microsoft FrameWork
- Microsoft SDK
When I try to install a .COM object (Mapwindow GIS), I have the following error: aximp.exe is not found
I do not know how to fix this error? They write a lot about this error on internet, but I don't understand registry...
Thank you for your help,
Cheers
Charles
|
|
|
|
|
Did you check 32/64bit issues? If your application is running on a 64bit OS, and you did not set it to x86, it will run as a 64bit application. When that COM object is a 32bit application, it won't find it. In such a case set the target platform to x86.
|
|
|
|
|
Hello,
Thank you for your quick reply. I just checked but it is not the problem. Both are 32bit
|
|
|
|
|
I've started a process that runs a command line executable and takes several seconds to return. I've attached/enabled events (OutputDataReceived and ErrorDataReceived) to enable the returning of STDOUT and STDERR messages from the process as they appear.
All works fine, and all events return the lines of text as they should for stdout and stderr as they appear. But I've noticed that the OutputDataReceived and ErrorDataReceived events continue to be fired and return output *even after* the process.Exited() event has fired.
I would have thought that the process had not yet completed until the last of Error and Output events have been caught/raised, but perhaps there is some kind of buffering going on within the Process that I am unaware of. If this is so, how can I know when the Process has *truly* completed-- as in the OUT and ERR data have fired for the last time *and* the process has truly exited? Ideally I would not read the contents of the OUT and ERR until the process is truly completed, therefore telling me that there is no output to follow the Exited() event.
|
|
|
|
|
Your observations of redirected output continuing after the Exited event has fired is accurate. The Microsoft examples are misleading but buried somewhere in the documentation is the information you need, which is that the redirected streams send DataReceivedEventArgs.Data == null when they close.
Process.Exited on it's own isn't much use when outputs are redirected and for all practical purposes it's best to wait until all redirected streams have sent null before declaring the process complete.
Alan.
|
|
|
|
|
Thanks for the response, Alan.
A quick check confirms what you stated--that the OutputDataReceived and ErrorDataReceived are raised with a Nothing value for e.data as the last call after returning their respective data. Since this call happens only once (for each Received event) and *only* after the data is completed, I can set a local flag within the process for each Received event when that happens. Between the two flags and the process.hasexited() property I can raise a custom event along the lines of:
If Process.HasExited() and OutputDataReceived_IsCompleted and ErrorDataReceived_IsCompleted then
Raise Event Process_HasTrulyCompleted()
EndIf
This seems to be the only guaranteed manner of knowing that all the conditions are met.
|
|
|
|
|
Hello !
I have an application that use entity framework 6 on vb.net and sql server.
Inside the app.config file there is the connection string to this entity that is created automatically during wizard.
But when I finish the application , this connection string is inside the file Myapplication.exe.confg , and the users can open this file and can change connection string.
Is possible to remove the connection string from this file and to create during application startup , and after to include this connection string to entity declaration for example Dim entity1 as Myentities(Connectionstring).
My question is that if this is possible , how can I create the connection string with all information needed .
My current connection string inside the app.config is :
<connectionStrings>
<add name="Entity1" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string="data source=PC1;initial catalog=MyDB;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Thank you !
|
|
|
|
|
You could ignore the one in the config file and hard-code the one you want.
You may be able to encrypt the one in the config file.
It's probably best to leave it the way it is and not change anything unless it becomes a problem.
You'll never get very far if all you do is follow instructions.
|
|
|
|
|
Yes , it's become a problem because users that don't know what they are doing , can open it and change the information.
So I want to know how can I create on runtime?
Thank you !
|
|
|
|
|
dilkonika wrote: it's become a problem because users that don't know what they are doing , can open it and change the information. That's a nonsense-argument.
There's more important things on the PC that they could break by accident. There's also no real way to abuse the information in the string. Stop being paranoid and come back if you got a good argument for hiding it.
dilkonika wrote: So I want to know how can I create on runtime? It's a string;
Dim MyString As String = "Hello World"
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you !
To be honest , I have 2 reasons why I want to create the connection string on runtime :
First : it's for security measure to not let users change the file.
Second : I'm making some changes in application and there are situations when a users can work with a local sql server database.And there are situations that they should work with a database (has the same structure as the local database) but on another server in network.
I know it's a string but does it have a specific structure ?
Or should I copy paste from the connection string that is inside app.config ?
Thank you !
|
|
|
|
|
If your application is under any path under Program Files, normal users cannot change the connection string. Well, they can load the .config file into Notepad, but they cannot save it.
Now, if your users are Administrators, well, there's nothing you can do to stop them.
Honestly, it's a waste of time to try and protect the connection string. If they want to screw with the app and ruin their data, that's their problem.
dilkonika wrote: I know it's a string but does it have a specific structure ?
The "structure" as you put it depends entirely on the database engine you're connecting to, the client (if any) you're using and the connection technology. Go to ConnectionStrings.com for the definitive list of connection string possibilities.
|
|
|
|
|
Thank you !
ok , let's forget the first reason.
but what about the second reason , it's possible to connect to another database on another server with app.config file ?
if there's please help me with some information.
Thank you !
|
|
|
|
|
You can put a mostly configured connection string in the app.config. This "template" connection string can have replaceable tags in it to put in a server\instance name and a database name. When you need the connection string, load it (ConfigurationManager class), replace the tags with the appropriate names (it is just a string afterall) and then you can use that in your database code.
|
|
|
|