|
Hi Tina,
I would suggest you to go with a event subscription based model to achieve this.
Please see Observer Pattern for details.
Make one project for Subject & Define all the other dll projects as observers. Let me know if you want to see a working code of it.
Regards,
Rahul Shukla
|
|
|
|
|
Hi,
I have numbers 1 to n(let it be 1 to 10).. They are in sequence and in ascending order but some of the numbers in between are missing. For example(1 2 3 5 6 9 10).
I need arrays from the numbers those are in sequence.
Like:
Array1: [1,2,3]
Array2: [5,6]
Array3: [9,10]
Note: It is also needed to calculate how many arrays we can get?
Can some body please help.
|
|
|
|
|
Well, sounds like you need to write some code. You have to step through until a number is not the next in sequence, then start a new array. You can build a list and call ToArray to make your arrays as you go.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
The problem is implementing, the logic u have given.
can u help me with sample code.
|
|
|
|
|
Well, the code someone gave you, doesn't look to me like it will work, but it should give you enough of a start to be able to do your own homework.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi Christian
Code is working
himanshu
|
|
|
|
|
Christian Graus wrote: Well, sounds like you need to write some code.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
This might help you.
List<int> al = new List<int>();
al.Add(1);
al.Add(2);
al.Add(3);
al.Add(5);
al.Add(6);
al.Add(11);
al.Add(12);
al.Add(13);
al.Add(21);
al.Add(22);
int x = 0;
List<int>[] ll=new List<int>[al.Count];
ll[x] = new List<int>();
for(int i=0;i<al.Count;i++)
{
if ((i + 1) == al.Count)
{
if (al[i] == al[i- 1]+1)
{
ll[x].Add(al[i]);
}
}
else
{
if (al[i] + 1 == al[i + 1])
{
ll[x].Add(al[i]);
}
else
{
ll[x].Add(al[i]);
x = x + 1;
ll[x] = new List<int>();
}
}
}
Array aa = ll.ToArray(); ;
himanshu
|
|
|
|
|
|
Hi.
I'm gonna get an Item on Mouse position during Mouse Double Click.
I've been using this method :
private void listView1_DoubleClick(object sender, EventArgs e)
{
Point mousePoint = new Point(MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y);
var item = listView1.GetItemAt(MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y);
if (item != null && item.Tag == null)
{
listView1.Invalidate(item.Bounds);
item.Tag = "tagged";
}
MessageBox.Show(item.Name);
}
Unfortunately it returns null.
Could you guide me how I can resolve it ?
Thanks.
|
|
|
|
|
Mohammad Dayyan wrote: MousePosition.X - this.Location.X, MousePosition.Y - this.Location.Y
What logic is this?
Mohammad Dayyan wrote: Unfortunately it returns null.
Here is what MSDN says,
The GetItemAt method, on the other hand, returns null reference (Nothing in Visual Basic) if there is no item at the specified location.
So it looks like there is no item in the location where you are specifying. I guess you need to handle MouseDown event and use the X and Y from the MouseEventArgs . Get the list item in MouseDown event and use it in the double click event.
Edit,
I found there is a MouseDoubleClick[^] event and that would be the right thing to use.
|
|
|
|
|
Thank a lot. my problem was solved
|
|
|
|
|
Use MouseDoubleClick event. This way:
private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) {
var item = listView1.GetItemAt(e.X, e.Y);
}
|
|
|
|
|
|
|
H! All
I have a problem regarding window service. When I tried to start the service from the Services, it gives me an error, "Error 1053: The service did not respond to the start or control request in a timely fashion"..
The code uses System.Threading not System.Timer..i tried to put an additional code to produce a log file so that i can see what is happening while starting in the services.., it executed the routine..from OnStart it calls a function and inside the function..it loops continuously..then i think it was five loops when the error showed up..it didnt pass to the OnStop method..
Another thing I am confused is that i can run or double click the EXE in the debug folder manually and it is running successfully. It seems that I am running an ordinary EXE not a windows service EXE..
BTW, this was built in C#.NET..
Anyone who knows this problem..Please help this is urgent..
Thanks in advance..Regards
|
|
|
|
|
Don't do operations that take long time on your start method. This error comes usually when the service can't start running in 30 seconds. Do all your long running tasks on a separate thread. What is your service doing on startup? Is it reading some files?
|
|
|
|
|
Thanks for your reply Navaneeth
Yes, the OnStart calls a function..here's the sample code..
public void Start()
{
int intervalEnqueue;
try
{
intervalEnqueue = 600;
timer1 = new Timer(new TimerCallback(LLPlusProcess), null, intervalEnqueue, intervalEnqueue);
}
.....and here are some content of the function.....
public void LLPlusProcess(object state)
GetSMSResult getIncomingSMSResult = new GetSMSResult();
getIncomingSMSResult = null;
service = new Service();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// get Incoming SMS with Waiting status
getIncomingSMSResult = service.GetSMS(System.Configuration.ConfigurationManager.AppSettings["clientAppKey"], System.Configuration.ConfigurationManager.AppSettings["enqueueStatus"], "Waiting", Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["enqueueRecord"])); <---- calls a web service function here
string getIncomingSMSResultResponse = getIncomingSMSResult.ResponseMessage;
System.Diagnostics.Debug.Write(getIncomingSMSResultResponse + "\r\n");
GetSMSResultMessage[] getIncomingSMSResultMessage = null;
getIncomingSMSResultMessage = getIncomingSMSResult.Message;
....etc...
If getIncomingSMSResultMessage is NULL then it will go here..else it will save the data in the database..
catch (Exception ex)
{
System.Diagnostics.Debug.Write("ENQUEUE [EX] : " + ex.ToString());
}
System.Threading.Thread.Sleep(100);
enqued = false;
}
else
{
System.Diagnostics.Debug.Write("\r\n ---- ENQUEUE PROCESS ON GOING ----\r\n ");
}
It will loop for how many times (as per my log files) but still it will end to error i mentioned..
But if i double click the exe file from debug folder..it run successfully..is it normal for a web service exe to be manually run? Some says it shouldnt be running that way..because exe file will look for the services for it to run...
Please help..Regards!
|
|
|
|
|
obrix_activex wrote: is it normal for a web service exe to be manually run?
Not usually, but you can write one that does.
What type of Timer are you using? I use a System.Timers.Timer for my Services.
|
|
|
|
|
H! PIEBALDconsult!
The program uses System.Threading...You may refer to my previous messages regarding my problem..
I'm confused to where is really the problem occurs..is it in the code or the way i built the service installer?
Thanks!
Regards
|
|
|
|
|
Hi Obrix!
m also facing the same short of problem to windows service
did u got solution??
please share
|
|
|
|
|
I debugged the program and the entire 'timer1_tick' event is SKIPPED. Here's the link to download the program. If anyone can fix my program, upload the edited program on sendspace and provide the link.
http://www.sendspace.com/file/j0tkw3[^]
I am pretty sure the mistake is in the timer1_click event or in the property of the timer1.
Also on a side note, I am new to the code project and I want to know if uploading a project file here is possible. If so, please tell me how.
|
|
|
|
|
No, you can't upload a project, and we probably won't download it. How about you give us the code that creates the timer ? You're saying you set a breakpoint in the timer and it never fires ?
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Open Form1 in the editor. Select the timer1 component - it's in the gray area below the form. Right-click on it and select "Properties". There's a list of properties on the right. Above that list is a small icon with an icon that resembles lightning. Click on it, and you'll get a list of events. Click on the Tick event and set it to timer1_Tick . That should hook up the handler.
Alternatively, you could do this from code. Double-click on your form in the editor to create an OnLoad event, and add this code;
private void Form1_Load(object sender, EventArgs e)
{
timer1.Tick += this.timer1_Tick;
} Welcome to CodeProject
I are nuts today
|
|
|
|
|
Wow - you can set timers in the designer ? I've never tried that ( nor am I likely to, but.... )
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|