Search Results

Search found 4334 results on 174 pages for 'sender'.

Page 148/174 | < Previous Page | 144 145 146 147 148 149 150 151 152 153 154 155  | Next Page >

  • Handling exceptions in Prism 4 modules

    - by marcellscarlett
    I've gone through a number of threads here about this topic with no success. It seems that in the App.xaml.cs of our WPF application, handling DispatcherUnhandledExceptions and AppDomain.CurrentDomain.UnhandledException don't catch everything. In this specific instance we have 7 prism modules. My exception handling code is below (almost identical for UnhandledException): private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) { try { var ex = e.Exception.InnerException ?? e.Exception; var logManager = new LogManager(); logManager.Error(ex); if (!EventLog.SourceExists(ex.Source)) EventLog.CreateEventSource(ex.Source, "AppName"); EventLog.WriteEntry(ex.Source, ex.InnerException.ToString()); var emb = new ExceptionMessageBox(ex); emb.ShowDialog(); e.Handled = true; } catch (Exception) { } } The problem seems to be the unhandled exceptions occurring in the modules. They aren't caught by the code above and they cause the application to crash without logging or displaying any sort of message. Does anyone have experience with this?

    Read the article

  • How to implement a multi-threaded asynchronous operation?

    - by drowneath
    Here's how my current approach looks like: // Somewhere in a UI class // Called when a button called "Start" clicked MyWindow::OnStartClicked(Event &sender) { _thread = new boost::thread(boost::bind(&MyWindow::WorkToDo, this)); } MyWindow::WorkToDo() { for(int i = 1; i < 10000000; i++) { int percentage = (int)((float)i / 100000000.f); _progressBar->SetValue(percentage); _statusText->SetText("Working... %d%%", percentage); printf("Pretend to do something useful...\n"); } } // Called on every frame MyWindow::OnUpdate() { if(_thread != 0 && _thread->timed_join(boost::posix_time::seconds(0)) { _progressBar->SetValue(100); _statusText->SetText("Completed!"); delete _thread; _thread = 0; } } But I'm afraid this is far from safe since I keep getting unhandled exception at the end of the program execution. I basically want to separate a heavy task into another thread without blocking the GUI part.

    Read the article

  • How do I ignore an "invalid" SSL certificate in Objective-C?

    - by ipwnstuff
    Currently I have: NSArray* array = [NSArray arrayWithObjects:@"auth.login",@"username",@"password", nil]; NSData* packed_array = [array messagePack]; NSURL* url = [NSURL URLWithString:@"https://192.168.1.149:3790/api/1.0"]; NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url]; [request setHTTPMethod:@"POST"]; [request setValue:@"RPC Server" forHTTPHeaderField:@"Host"]; [request setValue:@"binary/message-pack" forHTTPHeaderField:@"Content-Type"]; [request setValue:[NSString stringWithFormat:@"%d",[packed_array length]] forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:packed_array]; NSURLResponse *response; NSError *error; responseData = [NSMutableData dataWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]]; NSLog(@"response data: %@",[responseData messagePackParse]); NSLog(@"error: %@",error); - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace { NSLog(@"called canAuthenticateAgainstProtectionSpace"); return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]; } - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { NSLog(@"called didReceiveAuthenticationChallenge"); [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge]; } Which returns "Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid"…" How should I be implementing the answer from this question?

    Read the article

  • How to do a Translate Animation for both axis(X, Y) at the same time?

    - by user1235555
    I am doing something like this in my Storyboard method but not able to achieve the desired result. This animation I want to be played after the page is loaded. private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { CreateTranslateAnimation(image1); } private void CreateTranslateAnimation(UIElement source) { Storyboard sb = new Storyboard(); DoubleAnimationUsingKeyFrames animationFirstX = new DoubleAnimationUsingKeyFrames(); source.RenderTransform = new CompositeTransform(); Storyboard.SetTargetProperty(animationFirstX, new PropertyPath(CompositeTransform.TranslateXProperty)); Storyboard.SetTarget(animationFirstX, source.RenderTransform); animationFirstX.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = kt1, Value = 20 }); DoubleAnimationUsingKeyFrames animationFirstY = new DoubleAnimationUsingKeyFrames(); source.RenderTransform = new CompositeTransform(); Storyboard.SetTargetProperty(animationFirstY, new PropertyPath(CompositeTransform.TranslateYProperty)); Storyboard.SetTarget(animationFirstY, source.RenderTransform); animationFirstY.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = kt1, Value = 30 }); sb.Children.Add(animationFirstX); sb.Children.Add(animationFirstY); sb.Begin(); } Too cut it short... I want to write .cs code equivalent to this code <Storyboard x:Name="Storyboard1"> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="image1"> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="20"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="image1"> <EasingDoubleKeyFrame KeyTime="0:0:0.5" Value="30"/> </DoubleAnimationUsingKeyFrames> </Storyboard>

    Read the article

  • When calling a static method on parent class, can the parent class deduce the type on the child (C#)

    - by Matt
    Suppose we have 2 classes, Child, and the class from which it inherits, Parent. class Parent { public static void MyFunction(){} } class Child : Parent { } Is it possible to determine in the parent class how the method was called? Because we can call it two ways: Parent.MyFunction(); Child.MyFunction(); My current approach was trying to use: MethodInfo.GetCurrentMethod().ReflectedType; // and MethodInfo.GetCurrentMethod().DeclaringType; But both appear to return the Parent type. If you are wondering what, exactly I am trying to accomplish (and why I am violating the basic OOP rule that the parent shouldn't have to know anything about the child), the short of it is this (let me know if you want the long version): I have a Model structure representing some of our data that persists to the database. All of these models inherit from an abstract Parent. This parent implements a couple of events, such as SaveEvent, DeleteEvent, etc. We want to be able to subscribe to events specific to the type. So, even though the event is in the parent, I want to be able to do: Child.SaveEvent += new EventHandler((sender, args) => {}); I have everything in place, where the event is actually backed by a dictionary of event handlers, hashed by type. The last thing I need to get working is correctly detecting the Child type, when doing Child.SaveEvent. I know I can implement the event in each child class (even forcing it through use of abstract), but it would be nice to keep it all in the parent, which is the class actually firing the events (since it implements the common save/delete/change functionality).

    Read the article

  • Exception thrown when creating database

    - by Bob
    For some reason, I can't get embedded firebird sql to work on Windows using C#/.NET. Here's my code: string BuildConnectionString() { FbConnectionStringBuilder builder = new FbConnectionStringBuilder(); builder.DataSource = "localhost"; builder.UserID = "SYSDBA"; builder.Password = "masterkey"; builder.Database = "database.fdb"; builder.ServerType = FbServerType.Embedded; return builder.ConnectionString; } private void OnConnectClicked(object sender, EventArgs e) { string cString = BuildConnectionString(); FbConnection.CreateDatabase( cString ); FbConnection connection = new FbConnection( cString ); connection.Open(); //CreateTable(); //FillListView(); connection.Close(); } When I call FbConnection.CreateDatabase, I get the following exception: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) I'm very new to SQL and Firebird in general, so I'm not sure how to resolve this issue. Anyone?

    Read the article

  • Deleting items from datagrid (xml)

    - by Tonz
    Hello, I have a datagrid buttoncolumn which acts as delete buttons for my xml nodes. The elements are simply displayed in a boundcolumn, so there names get displayed. Each item generated gets a unique id (each time one is made id+++). My question his how can i remove a item (the entire element node with that certain id) when i click on one of the buttons in the bound column? <root> <element id="0"> <name>One</name> </element> <element id="1"> <name>Two</name> </element> </root> protected void dg_DeleteCommand(object sender, DataGridCommandEventArgs e) { XmlFunctions.Remove(index); }/*dg_DeleteCommand*/ (function on other class, where all my xml methods are written) public static void Remove(string index) { XmlDocument XMLDoc = new XmlDocument(); XMLDoc.Load(XMLFile); XPathNavigator nav = XMLDoc.CreateNavigator(); var node = nav.SelectSingleNode("/test/one[@id='" +???+ "']"); node.DeleteSelf(); XMLDoc.Save(XMLFile); } Edit: added datagrid <asp:View ID="viewDelete" runat="server"> <asp:DataGrid ID="dgDelete runat="server" AutoGenerateColumns="False" OnDeleteCommand="dg_DeleteCommand"> <Columns> <asp:BoundColumn DataField="name" HeaderText="names" /> <asp:ButtonColumn ButtonType="PushButton" Text="Delete" CommandName="Delete" ></asp:ButtonColumn> </Columns> </asp:DataGrid> </asp:View>

    Read the article

  • Modifying Django's pre_save/post_save Data

    - by Rodrogo
    Hi, I'm having a hard time to grasp this post_save/pre_save signals from django. What happens is that my model has a field called status and when a entry to this model is added/saved, it's status must be changed accordingly with some condition. My model looks like this: class Ticket(models.Model): (...) status = models.CharField(max_length=1,choices=OFFERT_STATUS, default='O') And my signal handler, configured for pre_save: def ticket_handler(sender, **kwargs): ticket = kwargs['instance'] (...) if someOtherCondition: ticket.status = 'C' Now, what happens if I put aticket.save() just bellow this last line if statement is a huge iteration black hole, since this action calls the signal itself. And this problem happens in both pre_save and post_save. Well... I guess that the capability of altering a entry before (or even after) saving it is pretty common in django's universe. So, what I'm doing wrong here? Is the Signals the wrong approach or I'm missing something else here? Also, would it be possible to, once this pre_save/post_save function is triggered, to access another model's instance and change a specific row entry on that? Thanks

    Read the article

  • Reload a UITable on the fly when editing a UITextField inside one of the cells

    - by Saze
    I have a UITable containing some customs UITableCells. Those cells contain a few UILabels and a UITextField. The datasource of the table comes from a main controller's property. (This controller is also the delegate and the dataSource for the table). Here's a simplified screenshot of the UI: Now, I need to update "on the fly" the content of all the UILabels when the user edits one of the UITextFields. To do so, at the I am listening to the "Editing Changed" event at the UITextField level. This triggers the following action: - (IBAction) editChangeHandler: (id) sender { MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [[delegate.viewController.myDataSourceArray objectAtIndex:self.rowIndex] setANumber: [theTextField.text intValue]]; [delegate.viewController reloadRows]; } The reloadRows method in the viewController is as such: - (void) reloadRows { NSLog(@"called reloadRows"); //perform some calculations on the data source objects here... [theUITable reloadData]; } My problem here is that whenever the user changes the value in the field, the reloadRows method is successfully called, so is apparently the reloadData but it also causes the keyboard to be dismissed. So in the end, the user can only touch one key when editing the TextField before the keyboard is dismissed and the table reloaded. Does anybody knows a solution to this or have experienced the same issue?

    Read the article

  • How do I manipulate the format on a DataGridView that is bound to a Data Source?

    - by Jack Johnstone
    I´m using SQL Server 2005 and Visual Studio 2008, C#. In the data source (the SQL Server data table) I use the DateTime format mm/dd/yyyy, however, in a forms overview (DataGridView) users would like to see a completely other format, with year, week number and day number of week (yyww,d) which is in string format. I´ve created an algorithm for the transformation between values (date to weekday), but can I populate the affected cells with yyww,d (string) instead of mm/dd/yyyy (DateTime)? This is what I´ve been testing out, without success (and note, it´s on the last line the problem becomes obvious, as the cell value won´t accept a string on runtime - it still wants to be a DateTime...) private void DataGridViewQueryFindRequests_CellFormatting( object sender, DataGridViewCellFormattingEventArgs e) { string weekAndDay = ""; DataGridViewCell cell = DataGridViewQueryFindRequests.Rows[e.RowIndex].Cells[e.ColumnIndex]; if (cell.ColumnIndex == 13 && cell.Value == null) mEmptyRow = true; if ((cell.ColumnIndex == 14 || cell.ColumnIndex == 15) && !mEmptyRow) { weekAndDay = ClassWeeksAndDates.dateToWeekNumber(Convert.ToDateTime(cell.Value)); cell.ValueType = typeof(string); cell.Value = weekAndDay; } }

    Read the article

  • VB looping complication

    - by user1819469
    I have to come up with a program that shifts names in a text box a random amount of times. I have gotten everything up to the point where the names shifts a random amount of times. It only shifts its once, but my messagebox appears through the code as many times as the names should be shifting once i click ok. Does anyone know why the loop is not working for the name shifts. I was thinking maybe the messagebox needs to control the loop, but I have searched endlessly and cannot find how that would be done. Any suggestions or referrals to other sites would be nice thanks. My code is below. Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim RandomNumber As Integer Dim min, max As Integer Dim temp, temp2, temp3, temp4, temp5, temp6 As String Dim i As Integer min = 3 max = 11 Randomize() RandomNumber = Int((max - min + 1) * Rnd() + min) temp = n1.Text temp2 = n2.Text temp3 = n3.Text temp4 = n4.Text temp5 = n5.Text temp6 = n6.Text For i = 0 To RandomNumber - 1 n1.Text = temp6 n2.Text = temp n3.Text = temp2 n4.Text = temp3 n5.Text = temp4 n6.Text = temp5 MessageBox.Show("Shift " & i & " of " & RandomNumber & " complete") Next End Sub End Class

    Read the article

  • progressbar not updating binding

    - by BoteRock
    I am trying to make a progress bar that updates when a property value changes I have followed other questions but i don't know what is wrong with it. This is XAML code: <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication1" x:Class="WpfApplication1.MainWindow" Title="MainWindow"> <Grid Margin="0,0,-8,1"> <ProgressBar Value="{Binding Progreso, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" Margin="105,95,207,350"/> <Button Content="Button" Click="Button_Click" Margin="218,232,333,217"/> </Grid> </Window> it is basically a progress bar with the binding and a button with a listener that increases Progreso by 10 this is the C# code: public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } public event PropertyChangedEventHandler PropertyChanged; protected void NotifyPropertyChanged(string sProp) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(sProp)); } } float progreso = 10; public float Progreso { get { return progreso; } set { progreso = value; NotifyPropertyChanged("Progreso"); } } private void Button_Click(object sender, RoutedEventArgs e) { this.Progreso = this.Progreso + 10; } } I tried to keep it simple but I couldn't get it to work, any help with this would be appreciated. edit: I've also tried UpdateSourceTrigger=PropertyChanged and that didn't work either

    Read the article

  • XML serialization of hash table(C#3.0)

    - by Newbie
    Hi I am trying to serialize a hash table but not happening private void Form1_Load(object sender, EventArgs e) { Hashtable ht = new Hashtable(); DateTime dt = DateTime.Now; for (int i = 0; i < 10; i++) ht.Add(dt.AddDays(i), i); SerializeToXmlAsFile(typeof(Hashtable), ht); } private void SerializeToXmlAsFile(Type targetType, Object targetObject) { try { string fileName = @"C:\testtttttt.xml"; //Serialize to XML XmlSerializer s = new XmlSerializer(targetType); TextWriter w = new StreamWriter(fileName); s.Serialize(w, targetObject); w.Flush(); w.Close(); } catch (Exception ex) { throw ex; } } After a google search , I found that objects that impelment IDictonary cannot be serialized. However, I got success with binary serialization. But I want to have xml one. Is there any way of doing so? I am using C#3.0 Thanks

    Read the article

  • Execute client & server side code with one click?

    - by Abu Hamzah
    i am not sure if my design have flaw but would like to know what others have to say, i am in a situation where i am trying to acheive two things in one click. using : asp.net web form i have a web form with few textbox and a gridview control and a button. if i click on the button i am executing two things 1) asynchronously get data from server to client (working great) and able to display the data in the textboxes. 2) same click i want to bind the gridview. <asp:Content ID="Content2" ContentPlaceHolderID="cphMaster" runat="server"> <asp:Label runat="server" ID='Label1' >Id:</asp:Label> <asp:TextBox ID="txtId" runat='server'></asp:TextBox> <asp:Button ID="btnSubmit" OnClientClick="LoadDataById();" runat="server" Text="Submit" onclick="btnSubmit_Click" /> <br /> <br /> <asp:TextBox ID="txtName" runat='server'></asp:TextBox> <br /> <asp:TextBox ID="txtPurpose" runat='server'></asp:TextBox> <br /> <br /> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </asp:Content> server side protected void btnSubmit_Click(object sender, EventArgs e) { GridView1.DataSource = laodData(int.Parse(txtId.Text)); GridView1.DataBind(); } Jquery: function LoadVisitBasicByVisitId() { ContactServiceProxy.invoke({ serviceMethod: "GetDataById", data: { request: request }, callback: function(response) { processCompletedContactStore(response); }, error: function(xhr, errorMsg, thrown) { postErrorAndUnBlockUI(xhr, errorMsg, thrown); } }); return false; } recap: 1) jquery script execute asynchronously to get data from server to client and display in the textboxes 2) server side code to bind the gridview.

    Read the article

  • Error In VB.Net code

    - by Michael
    I am getting the error "Format Exception was unhandled at "Do While objectReader.Peek < -1 " and after. any help would be wonderful. 'Date: Class 03/20/2010 'Program Purpose: When code is executed data will be pulled from a text file 'that contains the named storms to find the average number of storms during the time 'period chosen by the user and to find the most active year. between the range of 'years 1990 and 2008 Option Strict On Public Class frmHurricane Private _intNumberOfHuricanes As Integer = 5 Public Shared _intSizeOfArray As Integer = 7 Public Shared _strHuricaneList(_intSizeOfArray) As String Private _strID(_intSizeOfArray) As String Private _decYears(_intSizeOfArray) As Decimal Private _decFinal(_intSizeOfArray) As Decimal Private _intNumber(_intSizeOfArray) As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'The frmHurricane load event reads the Hurricane text file and 'fill the combotBox object with the data. 'Initialize an instance of the StreamReader Object and declare variable page 675 on the book Dim objectReader As IO.StreamReader Dim strLocationAndNameOfFile As String = "C:\huricanes.txt" Dim intCount As Integer = 0 Dim intFill As Integer Dim strFileError As String = "The file is not available. Please restart application when available" 'This is where we code the file if it exist. If IO.File.Exists(strLocationAndNameOfFile) Then objectReader = IO.File.OpenText(strLocationAndNameOfFile) 'Read the file line by line until the file is complete Do While objectReader.Peek <> -1 **_strHuricaneList(intCount) = objectReader.ReadLine() _strID(intCount) = objectReader.ReadLine() _decYears(intCount) = Convert.ToDecimal(objectReader.ReadLine()) _intNumber(intCount) = Convert.ToInt32(objectReader.ReadLine()) intCount += 1** Loop objectReader.Close() 'With any luck the data will go to the Data Box For intFill = 0 To (_strID.Length - 1) Me.cboByYear.Items.Add(_strID(intFill)) Next Else MsgBox(strFileError, , "Error") Me.Close() End If End Sub

    Read the article

  • How to replace same text in a text file

    - by user1688220
    i created a c# windows login form and i am saving username or password to a text file but every time i use same username or password that i have saved before it takes new place in that text file. But What i want is to replace the same username or password that is already saved in that text file. this is my code: private void button1_Click(object sender, EventArgs e) { try { FileStream fs = new FileStream("data.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); sw.Write("Email ID: "); sw.WriteLine(textBox1.Text); sw.Write("Password: "); sw.Write(textBox2.Text); sw.WriteLine(); sw.WriteLine(); sw.Flush(); sw.Close(); fs.Close(); } catch (Exception) { MessageBox.Show("Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } MessageBox.Show("DONE", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); textBox1.Clear(); textBox2.Clear(); }

    Read the article

  • Store data in tableview to NSUserDefaults

    - by Jozef Vrana
    Tricks.h file #import "Tricks.h" @implementation Tricks static NSMutableArray *trickList = nil; +(NSMutableArray *)trickList { if(!trickList){ trickList = [[NSMutableArray alloc]init]; } return trickList; } @end Tricks.m file @interface Tricks : NSObject @property(strong, nonatomic) NSString *trickName; Method for adding objects to array -(IBAction)saveAction:(id)sender { Tricks *trick = [[Tricks alloc]init]; trick.trickName = self.trickLabel.text; [[Tricks trickList]insertObject:trick atIndex:0]; [self.navigationController popViewControllerAnimated:YES]; } In .h file of UITabelview class I am making a reference to tricks class, but I am sure there is error on this line. @property (strong, nonatomic) Tricks *tricks; In cellForRow method I am storing data _trick = [[NSMutableDictionary alloc]initWithObjectsAndKeys:trick,nil]; NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults]; [defaults setObject:_trick forKey:@"numberArray"]; [defaults synchronize]; NSLog(@"%@",_trick); In .m class of UITableview in viewDidLoad I want to retrieve data if([[NSUserDefaults standardUserDefaults] objectForKey:@"numberArray"] != nil) { _tricks = [[NSUserDefaults standardUserDefaults] objectForKey:@"numberArray"]; } Thanks for advices

    Read the article

  • Weird send() problem (with Wireshark log)

    - by Meta
    I had another question about this issue, but I didn't ask properly, so here I go again! I'm sending a file by sending it in chunks. Right now, I'm playing around with different numbers for the size of that chunk, to see what size is the most efficient. When testing on the localhost, any chunk size seems to work fine. But when I tested it over the network, it seems like the maximum chunk size is 8191 bytes. If I try anything higher, the transfer becomes extremely, painfully, slow. To show what happens, here are the first 100 lines of Wireshark logs when I use a chunk size of 8191 bytes, and when I use a chunk size of 8192 bytes: (the sender is 192.168.0.102, and the receiver is 192.168.0.100) 8191: http://pastebin.com/E7jFFY4p 8192: http://pastebin.com/9P2rYa1p Notice how in the 8192 log, on line 33, the receiver takes a long time to ACK the data. This happens again on line 103 and line 132. I believe this delay is the root of the problem. Note that I have not modified the SO_SNDBUF option nor the TCP_NODELAY option. So my question is, why am I getting delayed ACKs when sending files in chunks of 8192 bytes, when everything works fine when using chunks of 8191 bytes? Edit: As an experiment, I tried to do the file transfer in the other direction (from 192.168.0.100 to 192.168.0.102), and surprisingly, any number worked! (Although numbers around 8000 seemed to perform the smoothest). So then the problem is with my computer! But I'm really not sure what to check for. Edit 2: Here is the pseudocode I use to send and receive data.

    Read the article

  • Some questions about focus on WPF

    - by ThitoO
    Hello, I've a little problem about focus on WPF. I whant to create a window, always on top, and that never get the focus (even if we click on it). Here's my solution : public partial class SkinWindow : Window { public SkinWindow() { InitializeComponent(); Loaded += ( object sender, RoutedEventArgs e ) => SetNoActiveWindow(); } private void SetNoActiveWindow() { WindowInteropHelper helper = new WindowInteropHelper( this ); SetWindowLong( helper.Handle, GWL_EXSTYLE, WS_EX_NOACTIVATE ); LockSetForegroundWindow( LSFW_LOCK ); } const int GWL_EXSTYLE = -20; const int WS_EX_NOACTIVATE = 134217728; const int LSFW_LOCK = 1; [DllImport( "user32" )] public static extern bool LockSetForegroundWindow( uint UINT ); [DllImport( "user32" )] public static extern IntPtr SetWindowLong( IntPtr hWnd, int nIndex, int dwNewLong ); } First problem : It's works, but I've to select an other window to "remove" the focus of my application (after the focus is not gave again, even if I click on my window). Second problem : When I move or resize the window, the modifications happens when I drop the window. Do you have any ideas / links / docs ? Thank you :)

    Read the article

  • VB.NET: WithEvents not Working

    - by Hei
    Hello All, I have the following classes: Public Class Email Private Shared ReadOnly EMAIL_REGEX = "\b[a-zA-Z]+[a-zA-Z0-9._+-]+@" + _ "[a-zA-Z0-9.-]+\.[a-zA-Z]{2,3}\b" Private _email As String Public Event emailCreated() ' Declare empty constructor private so the only way to create an object ' is using new (email) Private Sub New() End Sub Sub New(ByVal email As String) If Regex.IsMatch(email, EMAIL_REGEX) Then _email = email RaiseEvent emailCreated() Else Throw New Exception("Email Not Valid") End If End Sub ReadOnly Property Email() As String Get Return _email End Get End Property End Class And Public Class EmailForm WithEvents myEmail As Email Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try myEmail = New Email(TextBox1.Text) Catch ex As Exception MessageBox.Show("Exception: " & ex.Message) End Try End Sub Public Sub emailCreated() Handles myEmail.emailCreated MessageBox.Show("New Email Created") End Sub End Class If a create a wrong email lets say "email" the exception is correctly cached and a message is showed however is i input a valid email the event is not raised, the object is being created but no message is shown and no error or exception is thrown i suspect it has something to do with using "myemail = new Email(email)" but i have seen examples of using new with withevents with no problem. I would apreciate any input about this problem thank you

    Read the article

  • .net remoting - Better solution to wait for a service to initialize ?

    - by CitizenInsane
    Context I have a client application (which i cannot modify, i.e. i only have the binary) that needs to run from time to time external commands that depends on a resource which is very long to initialize (about 20s). I thus decided to initialize this resource once for all in a "CommandServer.exe" application (single instance in the system tray) and let my client application call an intermediate "ExecuteCommand.exe" program that uses .net remoting to perform the operation on the server. The "ExecuteCommand.exe" is in charge for starting the server on first call and then leave it alive to speed up further commands. The service: public interface IMyService { void ExecuteCommand(string[] args); } The "CommandServer.exe" (using WindowsFormsApplicationBase for single instance management + user friendly splash screen during resource initializations): private void onStartupFirstInstance(object sender, StartupEventArgs e) { // Register communication channel channel = new TcpServerChannel("CommandServerChannel", 8234); ChannelServices.RegisterChannel(channel, false); // Register service var resource = veryLongToInitialize(); service = new MyServiceImpl(resource); RemotingServices.Marshal(service, "CommandServer"); // Create icon in system tray notifyIcon = new NotifyIcon(); ... } The intermediate "ExecuteCommand.exe": static void Main(string[] args) { startCommandServerIfRequired(); var channel = new TcpClientChannel(); ChannelServices.RegisterChannel(channel, false); var service = (IMyService)Activator.GetObject(typeof(IMyService), "tcp://localhost:8234/CommandServer"); service.RunCommand(args); } Problem As the server is very long to start (about 20s to initialize the required resources), the "ExecuteCommand.exe" fails on service.RunCommand(args) line because the server is yet not available. Question Is there a elegant way I can tune the delay before to receive "service not available" when calling service.RunCommand ? NB1: Currently I'm working around the issue by adding a mutex in server to indicate for complete initiliazation and have "ExecuteCommand.exe" to wait for this mutex before to call service.RunCommand. NB2: I have no background with .net remoting, nor WCF which is recommended replacer. (I chose .net remoting because this looked easier to set-up for this single shot issue in running external commands).

    Read the article

  • Which approach is better in term of saving the data? How to handle this?

    - by dewacorp.alliances
    Hi there I have Telerik grid within a Telerik grid. Due to I have a different view between insert and edit mode, so as per suggested I have to use UserControl instead. Inside this control, it could have another Telerik grid plus bunch of ASP.NET textboxes. This thing works well. My dilemma is this: Scenario 1: Handling the save in the user control - OnClick event I have a button to save this. I need to get the value of the "selected grid" so I am using this snippet below and again works well. foreach (GridDataItem dataItem in radgrdTariffNetworkDistributorRateItems.SelectedItems) { string ID = dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex]["SupplierRateItemID"].ToString(); } But then how do I get the id of the parent grid where this control sit? I use the following this event to save: protected void bttnNetworkTariffReviewItemInsert_Click(object sender, EventArgs e) the e of course not the right one though?!?!? GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem; string reviewID = parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["ID"].ToString(); Scenario 2: Handling the save in the page instead (OnInsertCommand on the master grid) With this approach works well to get id of the grid etc BUT I am having a problem to get selected grid in the UserControl and plus couple controls value. How do I make this feasible? Logically, I should handle this at the user control level to save but again because the user control relying on the child grid I am having trouble to get this value. I am appreciated your suggestion.

    Read the article

  • redirecting _top page from asp:login control in iframe onloggedin

    - by jumpdart
    So yeah, Im building a little authenticated content(.NET app) to a large html site managed by another group. They are only comfortable with managing html so all my app content will be contained in iframes. Everything is working fine as far as navigation and calling services and whatnot but i cant bust out of the frame with my asp:login control. Im trying to register some JS on logged in but with no success. Thanks protected void login_LoggedIn(object sender, EventArgs e) { StringBuilder strScript = new StringBuilder(); strScript.Append("<script language='javascript'>"); string sHome = ConfigurationManager.AppSettings["AppHomePageURL"].ToString(); //strScript.AppendFormat("window.navigate('{0}');", sHome); //strScript.AppendFormat("parent.location.href='{0}';", sHome); //strScript.AppendFormat("window.open('{0}', '_top', '', false);", sHome); strScript.AppendFormat("top.location.href='{0}';", sHome); strScript.Append("WTF_let_me_outa_here();"); strScript.Append("</script>"); ClientScript.RegisterClientScriptBlock(typeof(Page), "LoginGO", strScript.ToString()); }

    Read the article

  • App_Themes Not Loading on Initial Load

    - by Jason Heine
    Hello, I have an application where different users can log in via a single portal login. When they log in, if they belong to more than 1 company they have to select the company they belong to. The theme will change if there is a custom theme for that company. Each page my application has inherits a "CustomPage" class Here is the code for the custom page: public class CustomPage : Page { protected void Page_PreInit(object sender, EventArgs e) { if (Globals.Company != null && Directory.Exists(Page.MapPath("~/App_Themes/" + Globals.Company.CompanyName))) { Page.Theme = Globals.Company.CompanyName; } else { Page.Theme = "Default"; } } } When the customer belongs to more than 1 company, and they select the company they belong to, the theme loads just fine. So, the problem I am having is this: If they belong to just 1 company, the company is automatically selected but the theme does not load right away. However, if I refresh the page, the theme loads just fine. Even the default theme will not load. The page has no css at all until I refresh. I am not using forms authentication and the default theme in the web config is "Default" <pages theme="Default"> Any thoughts to what might be going on? If you need clarification on anything, please ask. Thanks!

    Read the article

  • Displaying a message after adding duplicate records in database

    - by user1770370
    I wrote program in C# winforms and SQL server and LINQ to SQL. I use user control instead of form. In my user control, I put 3 textbox, txtStartNumber, txtEndNumber, txtQuantity. user define value of textboxes, when clicked button, it will insert some records according to the value of txtQuantity. I want to when duplicate number is created, it won't add to database and display message. how do i do? I must write code in code behind or server side? i must set this in store procedure or trigger? private void btnSave_Click(object sender, EventArgs e) { long from = Convert.ToInt64(txt_barcode_f.Text); long to = Convert.ToInt64(txt_barcode_t.Text); long quantity = Convert.ToInt64(to - from); int card_Type_ID=Convert.ToInt32(cmb_BracodeType .SelectedValue); long[] arrCardNum = new long[(to - from)]; arrCardNum[0]=from; for (long i = from; i < to; i++) { for(int j=0; j<(to-from) ;j++) { arrCardNum[j]=from+j; string r = arrCardNum[j].ToString(); sp.SaveCards(r, 2, card_Type_ID, SaveDate, 2); } } } Stored Procedure code. ALTER PROCEDURE dbo.SaveCards @Barcode_Num int ,@Card_Status_ID int ,@Card_Type_ID int ,@SaveDate varchar(10) ,@Save_User_ID int AS BEGIN INSERT INTO [Parking].[dbo].[TBL_Cards] ([Barcode_Num] ,[Card_Status_ID] ,[Card_Type_ID] ,[Save_User_ID]) VALUES (@Barcode_Num ,@Card_Status_ID ,@Card_Type_ID ,@Save_User_ID) END

    Read the article

< Previous Page | 144 145 146 147 148 149 150 151 152 153 154 155  | Next Page >