|
led mike wrote: Yes, obviously.
Aw, it doesn't help.
led mike wrote: Don't know. It depends on what is going on in CatalogService and associated aspects of the ASP.NET environment
Service talks to a repository which retrieves and stores data in the database. Furthermore the service enforces business logic rules, sometimes of course it just passes the call to the repository if there's nothing specific to do. It may use some session state variables as well. I think it's a standard thing, some people may call it a CatalogManager.
|
|
|
|
|
Pawel Krakowiak wrote: Service talks to a repository which retrieves and stores data in the database.
So if that object will use a Database connection then hopefully it is designed to use connection pooling. If not it should be. That would be one primary concern and is therefore handled with connection pooling not within the scope of instancing the CatalogService objects.
Based on what you have posted it's possible that the idea of making CatalogService a singleton into the premature optimizations are the root of all evil [^]category.
Now that what the object does is somewhat known I will also comment that the singleton like code you originally posted does not appear to conform to best practices. Given there is no need to ensure a single instance the lack of correctness will likely not result in any problems.
led mike
|
|
|
|
|
I posted the same question to ASP.NET forums and someone said to be careful with the second approach (the "master" class) as this brings thread safety issues to the table. I think it may be a valid reason not to do this, but so far it's the only one I got.
As for the singleton part - nay, I wouldn't plan to turn the services into singletons, I personally don't see a need for this. It's just that second approach which looks to have only one instance per the whole application.
|
|
|
|
|
Pawel Krakowiak wrote: as this brings thread safety issues to the table.
Yes, that is what I was referring to in my last post
Pawel Krakowiak wrote: It's just that second approach which looks to have only one instance per the whole application.
Yes. It is a non standard approach which produces a Singleton like design.
If you are interested you can find a long discussion on Singleton on the c2.com site I linked to in my last post. You will find the thread safety issue being discussed there.
led mike
|
|
|
|
|
I am attempting to recreate the behavior that Outlook does when a new message comes in. I would like a popup (form) to be displayed as topmost however not to have focus.
I am using a windows form to manage a series of messages that arrive on the fly. When a new message arrives I use ThreadPool.QueueUserWorkItem() to queue the message for creation of a popup (a simple windows form that is stylized). I would like the popup to come to the front however not take focus from the user. I have attempted to use several Win32 API's including SetWindowPos, SetForegroundWindow, ShowWindow to solve this problem. I can get topmost or focus to work, but not in conjuction. Does anyone have experience with this that may be able to point me the right direction?
|
|
|
|
|
Member 3922930 wrote: I would like a popup (form) to be displayed as topmost however not to have focus.
Member 3922930 wrote: I have attempted to use several Win32 API's including SetWindowPos
Well setting form.Topmost to true works for me.
led mike
|
|
|
|
|
Just set the TopMost property to true .
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Topmost of course makes the form come to the foreground, however it also gives it focus. As stated I dont want the form to have focus. Similar to how outlook comes to the foreground, however it does not take focus away from where you are typing.
|
|
|
|
|
You might have to somehow remember what control you are at before you have the form come up. Use TopMost to get the form on top, then set the focus back to where you were.
Also, don't down vote people who are trying to help you. It'll just piss them off and be less inclined to helping you in the future.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
My aplogizes. I miss read it. I thought it was similar to other sites, asking if the answer was the correct one.
Im not sure if remembering where the user came from is something that can be reasonably done. I would just like to not take focus away. Even if I kept track of where the user came from (say IE webpage) I am not sure I would be able to put the cursor back in the exact box where they were.
It appears this is possible at some level as Outlook does it.
|
|
|
|
|
No worries. Think of the numbers as being like number of stars
Not sure if you already saw this, http://bytes.com/forum/thread448993.html[^], even though it is in VB6, it shouldn't be hard to implement in C#
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Zocrates wrote: however it also gives it focus. As stated I dont want the form to have focus.
No, that's what I meant in my post. At least it works as you describe on my system (XP Pro, VS2005)
I tried with both Mozilla and Notepad in full screen and my form came to top but focus remained with the previous window (Mozilla or Notepad)
led mike
|
|
|
|
|
Hrm. You have a main form that creates another thread to populate a second form? And the form is always on top of each screen yet doesnt have focus? This doesnt seem to be the case when I try this.
|
|
|
|
|
I tested this with a C# Winforms and an MFC application.
1) Main dialog launches and sets a timer to like 10 seconds
2) I manually bring another application like Mozilla or Notepad to the top and give it focus
3) Main dialog timer event fires where my code creates a second form or dialog. During 2nd window initialization topmost is set
4) 2nd window appears on top of Mozilla or Notepad but Mozilla or Notepad maintain focus.
led mike
|
|
|
|
|
I made a test app like you mentioned above and I get the desired action. However when I add in the code to make this form being called by a new thread it no longer has the desired result.
I am using ThreadPool.QueueUserWorkItem(new WaitCallback(DisplayPopup), test) to create a new thread so the program can continue executing while the popup sits on the screen.
|
|
|
|
|
Zocrates wrote: However when I add in the code to make this form being called by a new thread
I don't know what that means "make this form being called by a new thread"?
Your forms must be manipulated from a GUI thread not a worker thread. You use Invoke to do that.[^]
led mike
|
|
|
|
|
The popup is a new form. The main thread processes the main form. The second form (popup) is managed by a different thread.
|
|
|
|
|
I was able to find a solution.
I was able to remove the dependency on the ThreadPool by using the modeless Show() instead of modal ShowDialog(). This allowed my program to continue to process while the popup was still showing. This handled the none maximized screens.
For the maximized screens I overrode the 'ShowWithoutActivation' property of the popup form.
All this of course with TopMost set to true.
|
|
|
|
|
Hrm. Actually it doesnt seem to work everytime. It works in both full screen mode and normal mode. Then it will stop working. Then I resize a screen or something and it works again....
|
|
|
|
|
It appears to be working on both full screen and normal screen until I close one of the popups(forms). Then the very next one will take focus away. After that it will begin working properly until I close one of the popups.
|
|
|
|
|
Hey guys
I have an MDI form that has a panel across the top for displaying business information. Whenever any of this panel is updated..I get this nasty bleeding effect where i can see through the borders of the labels etc. Has anyone ever seen anything like this?
|
|
|
|
|
Not seen this but have you tried calling its Invalidate() method to force a redraw?
If it's the panel's child controls that are the problem call Invalidate(true)
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi Guys,
i'm trying to sort the result from a datatable based on month and year.
getMonth below arranges d group header how i want. But the code puts on item per group. The prob, groups are repeating. Ex: May, 2008 repeats like five times but with diff items under it.
private string getMonth(string theDate)<br />
{<br />
string theMonth = theDate.Substring(0, theDate.IndexOf("/"));<br />
string theYear = theDate.Substring(theDate.LastIndexOf("/") + 1, 4);<br />
<br />
return (MonthName)int.Parse(theMonth) + ", " + theYear;<br />
}
Then i try to add the items, first into an array, then a ListViewItem
<br />
for (i = 0; i < dtAcct.Rows.Count; i++)<br />
{<br />
DataRow drow = dtAcct.Rows[i];<br />
<br />
ListViewGroup lvg = new ListViewGroup(getMonth(drow[0].ToString()));<br />
lvAccount.Groups.Add(lvg);<br />
<br />
string[] items = { Warehouse.DateMender(DateTime.Parse(drow[0].ToString())),<br />
drow[1].ToString(),
drow[2].ToString(),
setTransDetails(Int32.Parse(drow[3].ToString()), drow[4].ToString()) };<br />
<br />
ListViewItem lvi = new ListViewItem(items, lvg);<br />
lvAccount.Items.Add(lvi);<br />
}<br />
pls, can anyone help resolve this for me. Thanx a million!
He who goes for revenge must first dig two graves.
|
|
|
|
|
listen, do you filter/sort sql data on c#?
my advice is DON´T DO IT.
Create both read and write store procedures in sql and trigger them with c# events (like form_load or button_click or whatever).
It´s easier!!!
|
|
|
|
|
I'm trying to figure out the correct way of compiling the final version of a console application for other people to use.
I've done the "Build project" way, but then the user has to copy over all of the DLL files in my "bin" directory in order to get it to work. This way isn't very professional.
I've also done the "publish project" option, however when I publish it, I get 2 "application manifest" files (1 names "MyProject_1_0_0_0" and another simply names "MyProject"), a directory containing the DLL's (usually called "MyProject_1_0_0_0"), and a setup.exe file. I'm unsure of which ones to send over, so I just send them all over. This way isn't very professional either.
So, what's the correct way to compile my final version of a console application before handing it off to a user?
Thanks.
-Goalie35
|
|
|
|