elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Los 10 CVE más críticos (peligrosos) de 2020


  Mostrar Mensajes
Páginas: 1 ... 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 ... 77
251  Programación / .NET (C#, VB.NET, ASP) / Re: Duda con Thread ? en: 21 Agosto 2016, 21:03 pm
Ok lo tendré en cuenta, se me pasaba otra duda...

En el funcionamiento del Sub existirá el momento en que por ejemplo los modulos incrementen o se produzca un error y quisiera manejarlo...

Esto tendria que hacerlo con un raiseevent cierto ??

Salu2
252  Programación / .NET (C#, VB.NET, ASP) / Re: Duda con Thread ? en: 21 Agosto 2016, 20:37 pm
Gracias aclarada la duda es que en aquel tema pusiste el ejemplo pero no tenia bien claro el funcionamiento de esa función por el tema de los señales que me tenían inquieto..

Ok voy acomodarlo en el mismo Sub para ver como rula..

Una duda en el Form principal tengo 2 objetos un txt y un combo, para consultar el contenido de ambos desde una clase yo lo hacía:

frmprincipal.txtusername.text

Lo ideal seria que guardase estos valores en una clase que contenga esos parametros, cierto ?
253  Programación / .NET (C#, VB.NET, ASP) / Re: Duda con Thread ? en: 21 Agosto 2016, 18:59 pm
Pues busco saber si estoy por el camino correcto..

Si te distes cuenta modifique el código original porque necesito que el Loop no se detenga a menos que se haga true la cancelación...

254  Programación / .NET (C#, VB.NET, ASP) / Duda con Thread ? en: 21 Agosto 2016, 18:50 pm
Hola,

Leyendo este tema

http://foro.elhacker.net/net/iquesthacer_una_pausa_a_un_backgrounworker_en_vbnet-t405073.0.html;msg1906376

Me surge algunas dudas cuando trato de aplicarlo en mi proyecto.

Tengo un sub que verifica los procesos que estan corriendo en el Pc:

Tendría que quedar así supongo..

Código
  1. Private Sub MyWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) _
  2.    Handles MyWorker.DoWork
  3.  
  4.        Do While MyWorker.CancellationPending = False
  5.  
  6.                _busy.WaitOne(5000)        'Creo un intervalo de 5 segundos para ejecutar el Sub
  7.                CheckProcess()
  8.  
  9.        Loop
  10.  
  11.        e.Cancel = True
  12.  
  13.    End Sub


Tengo otro sub que igual verifica los módulos de una aplicación que supongo tendria que hacer otro backgroundworker
255  Programación / .NET (C#, VB.NET, ASP) / Re: Como puedo elaborar esta idea ? en: 12 Agosto 2016, 17:22 pm
El código esta perfecto lo que sucede es que no lo he podido implementar del todo por que hay cosas que no comprendo bien y no logro adaptarlo al proyecto que estoy usando como base.

El codigo que tengo envia asi:

Código
  1. _socket.Send(textSend.Text)

Mi pregunta hay alguna forma de mandar el tipo ClientInfo usando esta opción y poderlo recibir en el Servidor para hacer una comparación con los usuarios registrados.
256  Sistemas Operativos / Windows / Re: Paquete de idioma Windows 10 !! en: 12 Agosto 2016, 03:14 am
Muchas gracias ya lo baje y cuando tenga un time lo instalo para ver que sucede.

Muchas gracias desde ya.

SAlu2
257  Programación / .NET (C#, VB.NET, ASP) / Re: Socket Asincronico ! en: 11 Agosto 2016, 02:30 am
Código
  1. Imports System.Net
  2. Imports System.Net.Sockets
  3. Imports System.Text
  4. Imports System.Threading
  5.  
  6. ' State object for reading client data asynchronously
  7.  
  8. Public Class StateObject
  9.    ' Client  socket.
  10.    Public workSocket As Socket = Nothing
  11.    ' Size of receive buffer.
  12.    Public Const BufferSize As Integer = 1024
  13.    ' Receive buffer.
  14.    Public buffer(BufferSize) As Byte
  15.    ' Received data string.
  16.    Public sb As New StringBuilder
  17. End Class 'StateObject
  18.  
  19.  
  20. Public Class AsynchronousSocketListener
  21.    ' Thread signal.
  22.    Public Shared allDone As New ManualResetEvent(False)
  23.    Public Shared ClientsInfo As New List(Of UserInfo)
  24.  
  25.    ' This server waits for a connection and then uses  asychronous operations to
  26.    ' accept the connection, get data from the connected client,
  27.    ' echo that data back to the connected client.
  28.    ' It then disconnects from the client and waits for another client.
  29.    Public Shared Sub Escuchar()
  30.        ' Data buffer for incoming data.
  31.        Dim bytes() As Byte = New [Byte](1023) {}
  32.  
  33.        ' Establish the local endpoint for the socket.
  34.        Dim IpEndPoint As IPEndPoint = New IPEndPoint(IPAddress.Any, 11000)
  35.  
  36.        ' Create a TCP/IP socket.
  37.        Dim listener As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
  38.  
  39.        ' Bind the socket to the local endpoint and listen for incoming connections.
  40.        listener.Bind(IpEndPoint)
  41.        listener.Listen(100)
  42.  
  43.        While True
  44.            ' Set the event to nonsignaled state.
  45.            allDone.Reset()
  46.  
  47.            ' Start an asynchronous socket to listen for connections.
  48.            'MessageBox.Show("Waiting for a connection...", "Server Side")
  49.            listener.BeginAccept(New AsyncCallback(AddressOf AcceptCallback), listener)
  50.  
  51.            ' Wait until a connection is made and processed before continuing.
  52.            allDone.WaitOne()
  53.        End While
  54.  
  55.    End Sub 'Main
  56.  
  57.    Public Shared Sub AcceptCallback(ByVal ar As IAsyncResult)
  58.        ' Get the socket that handles the client request.
  59.        Dim listener As Socket = CType(ar.AsyncState, Socket)
  60.        ' End the operation.
  61.        Dim handler As Socket = listener.EndAccept(ar)
  62.  
  63.        ' Create the state object for the async receive.
  64.        Dim state As New StateObject
  65.        state.workSocket = handler
  66.        handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, New AsyncCallback(AddressOf ReadCallback), state)
  67.    End Sub 'AcceptCallback
  68.  
  69.    Public Shared Sub ReadCallback(ByVal ar As IAsyncResult)
  70.        Dim content As String = String.Empty
  71.  
  72.        ' Retrieve the state object and the handler socket
  73.        ' from the asynchronous state object.
  74.        Dim state As StateObject = CType(ar.AsyncState, StateObject)
  75.        Dim handler As Socket = state.workSocket
  76.  
  77.        ' Read data from the client socket.
  78.        Dim bytesRead As Integer = handler.EndReceive(ar)
  79.  
  80.        If bytesRead > 0 Then
  81.            ' There  might be more data, so store the data received so far.
  82.            state.sb.Append(Encoding.ASCII.GetString(state.buffer, 0, bytesRead))
  83.  
  84.            ' Check for end-of-file tag. If it is not there, read
  85.            ' more data.
  86.            content = state.sb.ToString()
  87.            If content.IndexOf("<EOF>") > -1 Then
  88.                ' All the data has been read from the
  89.                ' client.
  90.                MessageBox.Show("Read {0} bytes from socket. " + vbLf + " Data : {1}", content.Length, content)
  91.                MessageBox.Show(content, "Server Side")
  92.  
  93.                Send(handler, content)
  94.            Else
  95.                ' Not all data received. Get more.
  96.                handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, New AsyncCallback(AddressOf ReadCallback), state)
  97.            End If
  98.        End If
  99.    End Sub 'ReadCallback
  100.  
  101.    Private Shared Sub Send(ByVal handler As Socket, ByVal data As String)
  102.        ' Convert the string data to byte data using ASCII encoding.
  103.        Dim byteData As Byte() = Encoding.ASCII.GetBytes(data)
  104.  
  105.        ' Begin sending the data to the remote device.
  106.        handler.BeginSend(byteData, 0, byteData.Length, 0, New AsyncCallback(AddressOf SendCallback), handler)
  107.    End Sub 'Send
  108.  
  109.    Private Shared Sub SendCallback(ByVal ar As IAsyncResult)
  110.        ' Retrieve the socket from the state object.
  111.        Dim handler As Socket = CType(ar.AsyncState, Socket)
  112.  
  113.        ' Complete sending the data to the remote device.
  114.        Dim bytesSent As Integer = handler.EndSend(ar)
  115.        MessageBox.Show("Sent" & bytesSent & " bytes to client.", "Server Side")
  116.  
  117.        handler.Shutdown(SocketShutdown.Both)
  118.        handler.Close()
  119.        ' Signal the main thread to continue.
  120.        allDone.Set()
  121.    End Sub 'SendCallback
  122.  
  123. End Class 'AsynchronousSocketListener
  124.  

Como puedo acomodar tu codigo:

Código
  1.    Dim userInfo As UserInfo = UserInfo.FromStream(buferr completo de los datos recibidos por el socket)
  2.    users.Add(userInfo)

Gracias de antemano

258  Programación / .NET (C#, VB.NET, ASP) / Re: Algo curioso con las comillas en .NET ? en: 10 Agosto 2016, 15:02 pm
Lo pruebo hoy y te digo.

Salu2 y gracias !!
259  Sistemas Operativos / Windows / Paquete de idioma Windows 10 !! en: 10 Agosto 2016, 01:11 am
Tengo un Laptop DELL con Windows 10 Home 64x en ingles, quiero ponerlo en español, tengo que bajar algun paquete especifico para el o es algo general ?

Salu2 y gracias
260  Programación / .NET (C#, VB.NET, ASP) / Re: Socket Asincronico ! en: 9 Agosto 2016, 17:33 pm
No me habia fijado de que el codigo que muestras es del cliente pero yo me refiero al lado del servidor que no esta recibiendo lo que envio desde el cliente.

Salu2
Páginas: 1 ... 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 [26] 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 ... 77
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines