|
Hi Luc,
by now I'd still say that if B would need A then I'd treat them in the same plug-in. And if it was only to reduce chances of avoidable confusion So let's say they are on the same level of hierarchy and have something in common.
You write it in a way that makes me think it's an easy thing: "... possibly pass their capabilities around." or "signal that to all plug-ins present". How I would do that is exactly what I'm looking for - codewise. My confusion is at the point where I don't know which statement or method has to be in which class...
What I have: An interface IPlugin which has no methods yet, but defines the event "PlugInEvent" which I use for the purpose of testing (i.e. understanding). Each plugin has a PluginHandler Class which implements IPlugin, as well as the main MDI form. But the only way how I can consume plugin events from outside a plugin by now is to use Addhandler pluginMainform.event - but hardcoded stuff doesn't make a lot of sense considering the fact that a plugin is supposed to be more or less anonymous and flexible.
Your example hits the point: I'd be happy if I could make a plugin that signals "Free Beer for everyone" (e.g. when a certain button gets clicked) be noticed from any other plugins which would be interested in that . From between your lines in the example I guess a method in the IPlugin interface itself has to signal, right? But how does the interface itself receive a plugins event in the first place? Would I use addhandler inside the interface?
|
|
|
|
|
OK, here is the beginning of a concept, consider it pseudo-code (it will resemble C#); you didn't tell hardly anything of the kind of communication you want, so it may be rather abstract and besides the things you are looking for.
1.
the framework detects plugins and organizes plugin addition/removal.
It holds a list of plugins.
You can organize that in many ways.
2.
If you really want all plugins to be aware of each others presence, you could do this:
The framework signals those insertion/removal changes to all plugins.
public class PluginsCollectionsChangedEventArgs : EventArgs {
public IPlugin plugin;
public bool Removed;
}
interface IPlugin {
PluginsCollectionChanged(object sender, PluginsCollectionsChangedEventArgs e);
}
But I would not recommend this. I'd rather go for communication at a more functional level.
3.
if you have some objects with a producer-consumer situation, you could create a singleton class, that organizes the transportation. It could hold a list of producers and consumers, and a queue of goods. Each plugin could subscribe as producer and/or as consumer. The class could hold a queue of goods, with limited or unlimited capacity. It could signal consumers when goods become available; it could signal producers when space becomes available to store more goods produced.
4.
If the type of goods is not known beforehand, you could implement 3. as a base class and have the plugins create specialized transportation; and you could consider a generic implementation.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hello Friends,
I need to send an User Defined Type to a C++ DLL, but I am receiving "Bad DLL Calling Convention" error.
This "WORKS" (Without UDT):
In C++:
extern "C" __declspec(dllexport) int TestFx()
{
return 1;
}
---------------------------------------------------------
In VB:
Private Declare Function TestFx Lib "E:\DLL\DevCPP\CPPSource\Output\MingW\ProjectDlltest.dll" () As Long
But when I try with some UDT, it "FAILS":
In C++:
struct Vector
{
float x;
float y;
};
extern "C" __declspec(dllexport) int TestUDT(Vector *V)
{
return 1;
}
---------------------------------------------------------
In VB:
Private Type Vector
X As Single
Y as Single
End Type
Private Declare Function TestUDT Lib "E:\DLL\DevCPP\CPPSource\Output\MingW\ProjectDlltest.dll" (ByRef V as Vector) As Long
Dim Vec(1) As Vector
Dim RetVal as Long
RetVal = TestUDT(Vec(0))
MsgBox RetVal
Why the first program without UDT works and the second one not ?
I am using Dev-C++ for building the DLL.
Please Reply,
Thanks in advance.
|
|
|
|
|
Hi Friends,
I solved it out:
I Used __stdcall in combination with extern "C" __declspec(dllexport):
i.e., for e.g.
extern "C" __declspec(dllexport) __stdcall int FunctionName(Vector *V)
Thanks.
|
|
|
|
|
Hello,
Is Visual Studio 2010 (Visual Basic 2010) compatible with for example SQL 2005 ?
I have tried to convert a small application from VB 2008 to VB 2010 this application uses SQL 2005 and wont work directly.
I have installed a SQL 2008 and imported the database. The same application is running in VB 2010 with SQL 2008 without any problem.
IS this a setting or Service pack that need to be dont to acces SQL 2005 from VB 2010.
thanks
DCA
|
|
|
|
|
I think it should be compatible. Although can't find anything via google yet to say otherwise.
Is it giving you an error or what makes you think it is not working?
|
|
|
|
|
|
Hello,
I have the following question.
I have written a VB 2008 program for registering Rooms in a Hotel.
Using a Touch Screen for entering everythin so there is no keyboard and mouse installed on the PC.
So i have a buttom for every room on a main screen. When pressing for example room 2 , there is a new form that opens on top of the main form.
in the main programm is have frmxxx.show(). In the frmxxx() i have set in the load : FrmMain.enabled = false
So it is not possible anymore to click on the main form , so i have blocked that the users can change the form back to the main.
Now the problem : sometimes , the user is clicking to fast i think (before the frmMain.enabled = false) and the main window is coming on top of the frmxxx. so the mainform is hiding the smaller frmxxx so the user has a big main form wich is at that time disabled. so the screens are on top.
The only way to solve this is with a keyboard CTRL-TAB but because of the missing keyboard (due to the touch screen) it is not possible.
I have already tried to set the main form enabled = false before opening the frmxxx. but this is not working when the mainform is still active.
I dont want to hide the main form , so i wnat it set to disabled.
Does anyone can give me advise on this maybe stupid question.
Thanks
Best regards
DCA
|
|
|
|
|
sounds like you should be using ShowDialog instead of Show. ShowDialog will automatically 'block' the main form, so you don't need to worry about disabling it
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Hello,
Can i use the showdialog() with more that 2 forms.
So i have the mainform , i opens a second form with frmxxx.showdialog and on that second form there are again a few buttons wich i use to open a 3th form , can i use the same showdialog there ?
thanks
DCA
|
|
|
|
|
No, you can only use it with one form from the mainform, but YES you can keep calling ShowDialog from the Parent to Childs.
what you can also do is set the AlwaysOnTop property to true on the 'popup' form which will change the ZOrder of the forms, keeping it in front.
|
|
|
|
|
When i have 3 forms mainform , form1 and form2
From the mainform i need to open form1 wich need to be set active (on this time the main form may not be accessable).
From the form1 that is on top of the (blocked)mainform i need to open from2 wich comes on top of form1 , so form1 must also be disabled like frmmain. and form2 must be active only.
When clicking on the OK button on Form2 the form2 needs to be disapear and frm1 needs to come active again , frmmain is still deactivated until ok isclicked on frm1.
My problem was when using form.enabled that is was to slow and the user was clicking to fast so the wrong forms came on top of eachother and where locked .
can you help me with this please.
thanks.
DCA
|
|
|
|
|
You can use the ShowDialog() in this instance.
i.e. on the mainform call form1.showdialog, and on form1 call form2.showdialog
|
|
|
|
|
Thanks
That is the correct solution.
best regards
DCA
|
|
|
|
|
Hello, this is Vikash Gohil.
I have a windows Service that runs a thread on starting and the thread uses a while loop.
Now I want to Use Sleep function in my windows Service.
I want to know is it really OK or is there any kind of risk involved in making a windows service sleep.
the sleep time i want to use is around 55 to 58 seconds.
Please could anyone give me some guidelines on this topic.
Awaiting a reply soon.
Thanks in Advance.
|
|
|
|
|
|
Thanks daveauld for the reply.
The post was really helpful.
Thanks Again
|
|
|
|
|
Hello everyone,
I'm in dire need of figuring out the best data structure that would satisfy my needs and yet utilize the power of Parallel programing introduced in VS 2010.
What this data structure should be able to do efficiently is the following:
-be able to contain elements defined as a specific Structure
-handle tons of repetitive iterations and searches over its elements
-handle not so complex math operations
-be able to easily change in size when necessary without putting extra load on the CPU and RAM
-handle being parallelized
Hopefully, I've made myself clear enough.
Any thoughts would be greatly appreciated ...
Agarwaen
|
|
|
|
|
you can apply parallelism easily if your data needs are limited to:
- reading global data (i.e. across all threads) that no thread will be writing to;
- only writing data that is local to the thread.
So you could easily do a global dictionary, created beforehand, and read by all threads; each thread creating its own collection of results; and when they all finish, maybe join all those results.
If your app doesn't satisfy those restrictions, you need thread synchronization, such as locks, in order to avoid one thread reading data at the very moment it is getting modified by another thread (and for most data structures, a modification may temporarily cause an inconsistent, even an invalid, state).
From your (pretty abstract) data requirements I think you want to read data that is changing often, so you need the synchronization. I might have misunderstood though, you'll have to decide for yourself.
The Parallel goodies .NET 4.0 introduced don't provide data access synchronization for you; all they do is launch a number of threads, and wait for them to join. That is thread synchronization, not data synchronization.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Hi All,
I have one Excel sheet "Student.xls", which has different worksheet as "Sheet1","Sheet2"..like that.
Consider now "Sheet1"; it has 3 columns - "Name", "Age", "Sex". All these columns has row entries.
Now I have one access database, "alldata.mdb". It has One table "Record" which has 3 fields as same as column name of Excel sheet-- "Name", "Age", "Sex".
I want to populate this access database with the entries of Excel sheet from "Sheet1".
Can someone let me know how to do this?
I tried this:
// first connected xl datasheet:
Dim filename As String = "C:\Student.xls"
Dim con As String
con = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & filename & ";" & "Extended Properties=Excel 8.0;"
Dim connection As OleDbConnection = New OleDbConnection(con)
connection.Open()
The above Excel connection was succesful, but how to import the data from this excel sheet into the access database.
Please suggest.
Thanks,
R.S.
|
|
|
|
|
|
Good Article
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
|
|
|
|
|
I have gone through this, and I tried to implement somehow. The implementation is as follows:
// first connected xl datasheet:
Dim filename As String = "C:\Student.xls"
Dim con As String
con = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & filename & ";" & "Extended Properties=Excel 8.0;"
Dim connection As OleDbConnection = New OleDbConnection(con)
connection.Open()
// now copying the excel column into access database table columns:
Dim cmd As New OleDbCommand
cmd.Connection = connection
Try
cmd.CommandText = "SELECT * INTO [MS Access;Database=C:\alldata.mdb].[Record] FROM [Sheet1$]"
cmd.ExecuteNonQuery()
connection.Close()
MsgBox("The Import is Compelte")
Catch ex As Exception
MsgBox("Import Failed, correct Column name in the sheet!")
End Try
While executing I am getting following error:
The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
I am using Microsoft office 2007 with Access 2007 database.
Please tell me how to solve this?
Regards,
R.S.
|
|
|
|
|
The first thing to do would be to try and populate a dataset to prove the data is first getting read from Excel.
If you succeed with that then start trying to populate the access table.
I think for experimenting with new code, you are trying to do too much in one step. Start small, bite sized chunks, or you could end up getting confused by it all.
|
|
|
|
|
I am trying this:
Dim ds1 As New DataSet
Dim da As OleDbDataAdapter = New OleDbDataAdapter("SELECT * FROM [Sheet1$]", connection)
da.Fill(ds1)
But getting same error:
The Microsoft Jet database engine could not find the object 'Sheet1$'. Make sure the object exists and that you spell its name and the path name correctly.
|
|
|
|